I am learning OOP, SOLID principles and design patterns. I have designed data structure of in-memory database in C#. Please provide suggestions to improve it better considering solid principles, OOP and design patterns.
abstract class Entity
{
public string Name { get; set; }
public Guid Id { get; set; }
}
//singlton instance of Database class
sealed class DataBase : Entity
{
private static DataBase dbInstance; //single instance of Database
private List<Table> lstTables;// list of tables in database class
private DataBase() { }
public static DataBase GetDataBase() { if (dbInstance == null) dbInstance = new DataBase(); return dbInstance; }
//parse th query and prepares the command and execute ICommand.Execute and ICommand.Parse command
public void Execute(string query) { }
//factory method that returns COmmand object
private ICommand GetCommand(string query)
{
//returns appropriate ICommand object
throw new NotImplementedException();
}
public void AddTable(Table objTbl) { throw new NotImplementedException(); }
public void DropTable(string name) { throw new NotImplementedException(); }
internal Table GetTabelBYName(string name) { throw new NotImplementedException(); }
}
class Table : Entity
{
private List<Column> lstColumns; //list of columns
private List<Row> lstRows; // list of rows
public void AddColumn(Column clmn) { }
public void RemoveColumn(string clmn) { }
public void AddRow(Row row) { }
public Column GetColumnByName() { throw new NotImplementedException(); }
}
class Row : Entity
{
public List<Cell> lstCells
{
get;
set;
}
}
class Cell : Entity
{
public Column clmn { get; set; }
public object Value { get; set; }
}
class Column : Entity
{
public ColumnType type;
private Dictionary<string, object> lstAttributes;
}
enum ColumnType
{
INT, STRING, DECIMAL, DATETIME
}
enum CommandType { Select, Insert, Update, Delete, Alter }
interface ICommand
{
bool Parse();
bool Execute();
}
class SelectCommand : ICommand
{
public Table tbl { get; set; }
public List<Column> lstColumns { get; set; }
public string whereCondtin { get; set; }
public bool Parse()
{
throw new NotImplementedException();
}
public bool Execute()
{
throw new NotImplementedException();
}
}
class InsertCommand : ICommand
{
public Table tbl { get; set; }
public List<Cell> lstColumns { get; set; }
public string whereCondtin { get; set; }
public bool Parse()
{
throw new NotImplementedException();
}
public bool Execute()
{
throw new NotImplementedException();
}
}
class UpdateCommand : ICommand
{
public Table tbl { get; set; }
public List<Cell> lstColumns { get; set; }
public string whereCondtin { get; set; }
public bool Parse()
{
throw new NotImplementedException();
}
public bool Execute()
{
throw new NotImplementedException();
}
}
class DeleteCommand : ICommand
{
public Table tbl { get; set; }
public string whereCondtin { get; set; }
public bool Parse()
{
throw new NotImplementedException();
}
public bool Execute()
{
throw new NotImplementedException();
}
}
class AlterCommand : ICommand
{
public Table tbl { get; set; }
public List<Cell> lstColumns { get; set; }
public bool Parse()
{
throw new NotImplementedException();
}
public bool Execute()
{
throw new NotImplementedException();
}
}
throw new NotImplementedException();
this looks more like stub code which is off topic. – Heslacher Jun 6 at 5:41