Work In Progress

Object Oriented Programming(OOPs)

Introduction
Software components like patterns, architectures, frameworks built need a guide to follow to achieve their goal. This guide includes structures, best practices from a vast history of experience. Often we call it Object Oriented Programming concepts.
Terms Definitions
Entity An idea, something general, a philosophy, a resource, something significant, that can be given a name.
hobbit
Class A structure that represents an entity. This structure will contain concrete state and behaviour that an entity can contain and do.
                        
							   

public class Hobbit
{
    public String FirstName { get; set; }
    public String LastName { get; set; }
    public String Address { get; set; }
    public void GoOnAdventure()
    {
        //go on an adventure
    }
}
Object Object is an instance of a Class.
                        
                                

Hobbit bilbo = new Hobbit();
Hobbit frodo = new Hobbit();
Surely we know both bilbo and frodo are different Hobbits. But notice every Hobbit will have a FirstName, LastName and Address, which are different from each other. These are a set of concrete states that define and differentiate Hobbits. Also notice, every Hobbit can go on an adventure. bilbo and frodo went on their own adventures. Notice that initially bilbo and frodo had same Address at bag end, but later bilbo went to rivendale and his Address changed.
Coming back to OOP, As per a general approach, we need small components of an application that can be Constructed as an object, Re-Used again in another application, Assembled together to make a bigger component and Essential because what it does, no other component can do alone. This can be generalized to :
  • Identifying Classes(so that the objects can be constructed which will do all the work)
  • Separating Responsibilities(so that each object is essential, no overlapping functionalities)
  • Establishing Relationships(to make a bigger component)
  • Leveraging Reuse(by separating responsibilities)

Note, this is an iterative process. It may become a tough task to apply all the above right in the beginning of application design. You may come across different ideas of creating a better class or separating out a common functionality to another class, etc.

This doc will use C# and Visual Studio.

Identifying Classes from Requirements

Softwares are interactive visual outputs of business requirements. These visual outputs provide a way to achieve what a business requires. "Create a Customer Management System" business requirement can have a form that needs to be filled for a new customer, a list of existing customers with there names, address and the products they are subscribed to. etc.

These business requirements comes as a specification. A specification can be an email, or a word document or any other readable medium. It can contain a prototype of final required output. For example, the customer form should look like this, this is a product page describing its details. etc.

We will start with Analyzing the Problem, Identifying the Name(yes just the name, a noun) of the Entites and Define appropriate Members(state and behavior Names)

Eventually we will cover two of the OOP pillars

  • Abstraction
  • Encapsulation

Let's get started.
Here are the business requirements

                 We recently aquired ABC corporation, and we need to create a new Customer Management System. It will be called LOTR Customer Management System.
                
                    It should manage business, residential, government and educator types of customers and should include Customer's name(Last name, first name), Email address, Home and work addresses
                
                    It should be able to manage both our current products and ABC corporation's products. It should be able to handle the product name, product description, and its price
                    Also, it should accept orders from customers either online or through our call center. Collect the customer information, order date, shipping address and products and quantities ordered.

Time to analyze and extract the Entity(Class) out of the requirements

                 We recently aquired ABC corporation, and we need to create a new Customer Management System. It will be called LOTR Customer Management System. This can give our project name, lets say LOTR_CMS
                
                    It should manage business, residential, government and educator types of customers and should include Customer's name(Last name, first name), Email address, Home and work addresses. This talks about Customer
                
                    It should be able to manage both our current products and ABC corporation's products. It should be able to handle the product name, product description, and its price. This talks about handling Product
                    Also, it should accept orders from customers either online or through our call center. Collect the customer information, order date, shipping address and products and quantities ordered. This talks about handling an Order

We could have identified more classes, or omitted some classes. This could be the iterative process we talked about, manage the need of creation, refactoring, or omitting classes. Below is what we found out as yet.
Customer
Name
Email Address
Home Address
Work Address
Product
Product Name
Description
Current Price
Order
Customer
Order date
Shipping Address
Product
Quantity