Please enable JavaScript.
Coggle requires JavaScript to display documents.
Object Oriented Analysis & Design (01- Core concepts (What's an…
Object Oriented Analysis & Design
01- Core concepts
Why use object oriented language?
Procedural languages - long piece of code divided into procedures or sub-routines
Object oriented language- large piece of code is divided into small objects
Each object will contain data n logic, each object is like a mini program
Each object will communicate with each other
Examples: Employee, BankAccount, Game, Player, Spaceship etc.
What's an Object?
Real world example: Car, Table, Television, Bike etc
One object can contain other objects
Each object is unique
Objects has attributes like color, taste etc
Objects has behaviors like an Airplane can fly, a Car can be driven etc
Objects in computer- Bank Account, Person, Player
We can have real world objects in a computer program but we can have something virtual which we cant touch like Date, Time, Account
Each virtual object is also different like one Bank Account cannot be same to other, each can have different attribute values
How to identify and object - Can you use The in front of it
What's class?
Objects and classes are tightly related to each other
We use classes to create an object
Class isnt an object, it describes ab object, its a blueprint, its a definition of an object
Define the class once and create many objects from it
A class has three things- name, attributes n behaviors
Other names for class name is type, attributes is properties or data, behaviors is method or function
What's abstraction?
virtual vs physical
Encapsulation
Keeping things together n protecting it
properties n methods are kept hidden
black boxing, telephone example
Inheritance
code using from existing class
Superclass-subclass
Polymorphism
one object many forms
sign does addition n string concatenation
02- OOA & D
Understanding
The process to identify what classes do we need n what they will do?
How - Gather requirement, describe the app, identify the main objects, describe the interactions, create class diagram
Defining requirements
Functional requirements - what does it do? like features/capabilities
Non functional requirements- What else? like documentation/help, legal, performance, support, security
Examples of functional n non functional requirements
FURPS - Functional, Usability, Reliability, Performance, Supportability
"+" => Design requirements, Implementation requirements, Interface requirements, Physical requirements
Requirements do change
UML- Unified Modelling Language
Use to draw system diagrams
class diagrams, sequence diagrams etc
03- Utilizing Use Cases
Use case
title- What is the goal
Actor- Who desire it
Scenario- How it is accomplished
title examples- register new member, transfer funds, purchase items, create new page
actor examples- user, customer, member, admin, ACMESystem
scenario- step by step actions of goal to achieve
Identifying the actors
actors can be normal users or an external system
identifying the scenarios
user centric, scenarios can have extensions, they may not be straight forward, e.g. while buying an item what happens if the item is out of stock
use active voice and non technical language
focus on intension
Diagramming use cases
Employing user stories
As a...(type of user) I want...(goal) So that...(reason)
As a Bank customer, I want to change my pin online, so that I dont have to go into a branch
04- Modelling the App
Creating a conceptual model
identifying the most important objects in the system
Identifying the classes
list of nouns from the use cases
Identifying class relationships
uses relationship like customer uses shopping cart or shopping cart contains items
1...* relationship
Identifying class responsibilities
verbs in the use cases
associate them with the objects
Using CRC cards
once CRC card for one class
classname, responsibilities, collaborators
05- Creating classes
Creating class diagrams
Converting class diagrams to code
Exploring object lifetime
new keyword
constructor
constructor overload
Using static or shared members
one copy across all the objects
06- Inheritance & Composition
Identifying inheritance situation
IS-A relationship
A Car is a vehicle, A car is a bus, well not!
Group your classes together, see if you have any relationship between them, create an inheritance hierarchy
override properties and methods
Dont go for deeper level of inheritance tree
Using inheritance
extends keyword
super keyword
Using abstract classes
a class that cannot be instantiated
Using interfaces
its a contract
you can program to interface rather than implementation
Using aggregation & composition
HAS-A relationship
a customer has a address, a car has a engine
07- UML Concepts
Sequence diagrams
diagram to lifetime of an object
UML Diagrams
class, use case, object, sequence, state, activity, deployment, package, component, profile, communication, timing, composite, interaction
UML Tools
Visio, Omnigraffle, gliffy, creately, lucidchart
08- Object oriented design patterns
Well tested solutions to common problems
general solutions
creational, structural, behavioral
09- Object oriented design principles
Guidelines, general principles
DRY- Dont Repeat Yourself
YAGNI- You Aint Gonna Need It
solves todays problems
Code smells
long methods
very short or long identifiers
pointless comments
GOD object
Feature envy
SOLID Principles
Single Responsibility Principle
one reason to exist, one reason to change
Open closed principle
open for extension but closed for modification
Liskov substitution principle
derived classes must be substitutable for there base classes
Interface seggregation principle
have multiple smaller interfaces
Dependancy inversion principle
depend on abstractions, not on concretions
GRASP