3 - MiraSamir/Paint-Application GitHub Wiki
1 – MVC pattern:
“MVC Pattern stands for Model-View-Controller Pattern. Model–view– controller (MVC) is a software design pattern for implementing user interfaces on computers. It divides a given software application into three
interconnected parts, so as to separate internal representations of information from the ways that information is presented to or accepted from the user.”
2 – Strategy Design Pattern:
“The strategy pattern (also known as the policy pattern) is a software design pattern that enables an algorithm's behavior to be selected at runtime. The strategy pattern defines a family of algorithms,
encapsulates each algorithm, and makes the algorithms interchangeable within that family.
Strategy lets the algorithm vary independently from clients that use it.”
Strategy Design pattern is used in implementing both Save and Load techniques, since “Paint” Application enables users to save/load both xml and json files. Strategy Pattern helps in having two different implementations depending on user’s desire for one option.
3- Command Design Pattern:
“In object-oriented programming, the command pattern is a behavioral design pattern in which an object is used to encapsulate all information needed to perform an action or trigger an event at a later time. This information includes the method name, the object that owns the method and values for the method parameters.”
Object Oriented Principles:
- IShape , ILoad , ISave interfaces defines the contract/ methods used by classes which implements them.
- Abstract Shape Class implements IShape, defines the common attributes and methods shared by all shapes which extends Shape Class.
- Abstract Command Class which is extended by History, Save and Load Classes to be Invoked through Memory Invoker.
- Abstract Polygon Class defines common attributes and methods shared by Polygon shapes.
- Abstract OptionEngine Class defines common attributes and methods shared by the core painting classes: Drawing, Coloring, Moving and Resizing Classes.
- Controller Class deals with drawing paint tools through an OptionEngine.
- Controller Class deals with Memory tools through an Invoker instance which Invokes a Command to be executed.
- LineSegment, Ellipse, Rectangle, FreeShape Classes inherit their common attributes and methods from Abstract Shape Class.
- Circle class inherits its attributes and methods from Ellipse Class.
- Square class inherits its attributes and methods from Rectangle Class.
- Drawing, Moving, Resizing, Coloring engine Classes inherit their common attributes and methods from an Abstract OptionEngine Class.
- Memory classes e.g. Save, Load , History classes inherits their common execute method from an abstract Command Class.
Encapsulation principle is preserved in “Paint” application with each Class having private attributes can only be accessed through getters and setters.