In This article:
- You will able to learn basic elements of a Object Oriented Design.
- You will able differentiate design pattern and design principle.
- At the end you will get some useful links and books to read.
- Finally you will bag at least one more interview question and their clarification.
- Why these definitions and descriptions needed–
Most of the time developers have to work on enhancements based projects, where they have to understand the code which is already written by some other people. The understanding of code base takes time based on project architecture. Then during analysis of code a query always tickles, in one corner of the mind of the developers, “why-this-extra-class-needed” or some other similar lines. This type of queries came in mind when one is not aware of the paradigm used and patterns. There are several books and sites you will find on this but here you will get the base of a good design. This is not so fancy, but if you will burn it in your mind- your understanding will be much deeper.
- Stands for Object Oriented Programming.
- Object-oriented programming (OOP) is a programming paradigm that represents concepts as “objects” that have data fields (attributes that describe the object) and associated procedures known as methods. Objects, which are instances of classes, are used to interact with one another to design applications and computer programs.
- OO basics are-
- Please avoid writing it as OOPs or OOPS. Please see this article.
OO Design Principle—
- OO principle is a set of guidelines that ensures OOP concept.
- Based on the OOP concept, this defines ways to design better way, a better design.
- The basic OO design principle is SOLID.
- SOLID is known as-
- Single Responsibility Principle
A class should have only one reason to change.
2. Open Close Principle
Software entities like classes, modules and functions should be open for extension but closed for modifications.
3. Liskov’s Substitution Principle
Derived types must be completely substitutable for their base types.
4. Interface Segregation Principle
Clients should not be forced to depend upon interfaces that they don’t use.
5. Dependency Inversion Principle
High-level modules should not depend on low-level modules. Both should depend on abstractions.
Abstractions should not depend on details. Details should depend on abstractions.
OO Design Pattern-
- A Design pattern provides a general solution to a design problem.
- Please note “design pattern” can be applied to noon object oriented word too. So A OO design patterns (OODPs) are those which provide a general solution to object oriented design based OO principle.
- Design patterns are discovered, not invented.
- There are several ways to define OODPs and most famous one is BSC [Behavioral Structural Creational].
- Understanding BSC-
- To create objects one need of classes. This is start of design.
- A class must have well defined attributes. The design solution made to compose class structure is known as Structural patterns.
- Now you have class, to create objects one needs to create object(s). The design solution made to instantiate a class or classes is known as Creational patterns.
- Once object instantiated, think of objects interactions. So those design solutions which are concerned with object interactions are known as Behavioral patterns.
- Best practices can be used in OODPs to avoid business errors or run time errors.
- There can be multiple techniques to do some tasks but to do in efficient and effective way can be said Best practices.
In java there are multiple ways to iterate a map, but if you want to get just list of keys do not use iterator or entryset, but use keyset.
Type safety can be another example of best practices.
So by understanding above definitions we can conclude that design patterns uses to implement an OO design problem. These patterns use OO Principles and Best practices to ensure OO paradigm with highly scalable and efficient design.
Just start with basics principles and design. If you don’t know which way to go, then follow the links and books given in useful link. Don’t just dive in technologies; first grasp the basics of all these technologies.
- Notes on basic design principle and pattern-
- Some more design principle can be found at this site
- The best book to start with design pattern is-
Print this article: