Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Design

No description
by

Xuelan Mei

on 13 March 2014

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Design

Design
Design
Methodology
Design Principles
Conclusion
OOD/OOA
Object Oriented Deisgn/Analysis
What are the classes
What are they doing
How they collaborate
Principle: GRASP
Tool: UML, CRC
DDD
Domain Driven Design
Emergent Design
Speculation: over or under consideration
- "what if" --> over design --> waste
- "oh, I didn't see that" --> bug --> waste
In the end, the source code is the design
S.O.L.I.D
Single Responsibility Principle
One Software element
should
do one thing

and
do it well
Open Close Principle
One Software module
should
open for extension
and
close for modification

Liskov Substitution Principle
Subtypes must be
Substitutable
for their base type
Interface Segregation Principle
No client
should be forced to
depend on methods it does not use
Dependence Inversion Principle
High-level modules should not depend on low-level modules. Both should depend on abstractions

Abstractions should not depend upon details. Details should depend upon abstractions
Duplication code often suggest a separate responsibility
Code enclose in a clause suggest a responsibility

Data with different change rate suggest different responsibility
Switch/Case suggest different responsibility
void sort(Student students[]){
for(int unsortLen = 5-1; unsortLen > 0; unsortLen --)
for(int pivot = 0; pivot < unsortLen - 1; pivot ++)
if(student[piovt].score > student[pivot + 1].score)
swap(student, pivot, pivot + 1);
}
void sort(Student students[]){
for(int unsortLen =
5
-1; unsortLen > 0; unsortLen --)
for(int pivot = 0; pivot < unsortLen - 1; pivot ++)
if(student[piovt].score > student[pivot + 1].score)
swap(student, pivot, pivot + 1);
}
void sort(Student students[]){
for(int unsortLen = 5-1; unsortLen > 0; unsortLen --)
for(int pivot = 0; pivot
<
unsortLen - 1; pivot ++)
if(student[piovt].score > student[pivot + 1].score)
swap(student, pivot, pivot + 1);
}
Example:
Hints:
Code to interface

Encapsulate what variase
- value --> variable
- behavior --> interface
- type --> template
- spelling --> macro
EXAMPLE:
void RobertDriver::startCar(Car car){
...
}

void EPolice::MonitorCar(Car car){
....
}
Hints:
DBC: Design by Contract
Emergent Design
Messaging
- shared memory
- socket
E
Class Me{
public:
virtual void programming(Program p) = 0;

virtual void cooking(Food f) = 0;
virtual void cleaning(Clothes c) = 0;
};
class Programmer{
public:
virtual void programming(Program p) = 0;
};
class Mammy{
public:
virtual void cooking(Food f) = 0;
virtual void cleaning(Clothes c) = 0;
};
class Me : public Programmer, Mammy{ ... };
class Button{
private:

Lamp lamp;

public:
void Poll() {
if (/*some condition*/)
lamp.TurnOn();
}
}
class Button{
private:
Switchable switchable;

public:
void Poll() {
if (/*some condition*/)
switchable.TurnOn();
}
}
Law of Demeter
Each unit should have only limited knowledge about other units

Only talk to your immediate friends
void chargeCustomer(Customer *customer, Currency amout){
Wallet *customerWallet = customer->getWallet();

if (customerWallet->cashAmount() > amount)
customerWallet->fetchCash(amount);
else
chargeCustomerByCreditCard(customer, amount);
}

Casher -> Customer -> Wallet -> CashAmount
DRY -- Don't repeat yourself
Don't talk to strangers
Tell, don't ask
YAGNNI
Pass all tests
Maximize Clarity
Minimize Duplication
Has fewer elements
You are gonna not need it
Full transcript