Yiğit Oğuz
26.02.2020
yigitoguz.com
Object Oriented Design is the concept that forces programmers to plan out their code in order to have a better flowing program.
Language Consept
There are five general design principles of object-oriented programming intended to make software more understandable, extendable, maintainable and testable.
One class should have one and only one responsibility
public class Account
{
public void ChangeUserName()
{
}
public void SetAccountActivate()
{
}
}
Software components should be open for extension, but closed for modification
public class Account
{
public void ChangeUserName()
{
}
public void SetAccountActivate()
{
}
//?
public void SendEmail()
{
}
}
Derived types must be completely substitutable for their base types
public class Account : AbstractMember
{
public override void Unsubscribe()
{
//TODO:
}
}
public class Admin : AbstractMember
{
public override void Unsubscribe()
{
//?
}
}
Clients should not be forced to implement unnecessary methods which they will not use
public class Account : ICreateNewProduct
{
public void CreateNewProduct(..)
{
throw new NotImplementedException();
}
}
public class Admin : ICreateNewProduct
{
public void CreateNewProduct(..)
{
//TODO
}
}
Depend on abstractions, not on concretions
In software engineering, a design pattern is a general repeatable solution to a commonly occurring problem in software design. A design pattern isn't a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations.