Software Design - vidyasekaran/current_learning GitHub Wiki

https://www.youtube.com/watch?v=FLtqAi7WNBY

Software Design Tutorial #1 - Software Engineering & Software Architecture

Read requirement and come up with class diagram

Design Problem - Tech with Tim School of programmers

The tech with tim school of programmers needs a new system to track all of its students, professors and courses. it wants to keep track of what courses are offered, who teaches each course and which students are enrolled in those courses. it would also like to be able to track the grades of each of its students across all courses. for each student and profesor the school needs to know their address, phone number and name and age.

Each course has max and min number of strudents that they can enrol. if the ma number of students is not reached then the course will be cancelled. each course is taught by at least one profesor but sometimes may be taught by many.

Professors are salaried employees at the tech with tim school of programmers and thereforme we need to keep track of how much they make each year. if a professor teaches more than 4 courses in a sem then they are granted one time bonus of $20,000.

Students can be both local or international students and full or part time. A student is considered a part time student if they are enrolled in 1 or 2 courses during any given semester. the max amout of courses a student may be enrolled in a t one time is 6. Students receive grades from each course. these grades are numberic in the range of 0 - 100. any students that have an average grade across all enrolled courses lower than 60^ is said to be on academic probation.

NOTE: This system will be reset and updated at the end of each sem.

Make note or points of what ever the system has to track and perform from the requirement. Translate the requirements into a program Need to come up with number of Class diagrams required in UML we will use OOP

Think of all of the main objects or classes while doing that think of what are you going to keep track of

example : students courses, grades

Classes

Student Professors Course

I need to keep trak of Grades, keep track. We miss class for who is enrolled in what course and what grades each student have?

So i come up with Enroll class so that i can keep track of which student

Student Professors Course Enrol

Enrol will link Students and the courses together and may store date enrolled in course.

Now list down each class and map functionalities in the requirement in terms of attribute and methods

Student

  • international: boolean

  • isParttime() : boolean (this method check number of courses and return value as to whether parttime or full time)

  • isOnProbation() : boolean

What these methods are going to do is look into the attributes of the student evaluate and give us an answer like are they partime or fulltime/ is on probation.

  1. Focus on Attributes and fill in the classes with Attribute (Static and Dynamic)
  2. Now focus on Associations

We have introduced a class common to student and professors such as Person and Address..

Student

  • international: boolean

  • isParttime() : boolean (this method check number of courses and return value as to whether parttime or full time) Professors

We have shared info between student and professor so we come up with person class

Address

  • coutry : string
  • state: string
  • street address: string
  • city: string
  • postal code: string

Person

-firstName: string -lastName: string -age (DONT HAVE THINGS THAT CHANGE INSTEAD HAVE A DOB)

  • dateOfBirth : date
  • phoneNumber: String

Professor

  • salary: float

Course

  • name : string
  • code : string
  • minStudents : int
  • maxStudents : int
  • start: date
  • end : date
  • isCancelled() : boolean (checks number of students registered and return true or false)

Enrol (keep track of students enrolled)

  • date : date (when did a student enrol)
  • grade : float (students)

We now have all classes, now focus on Associations - example: Each Student or professor is going to

have an address, each student will be enrolled in a course, professor teaching a course.

Associations link 2 classes - Be focused on how these classes are going to interact and not think about implementation...

Come up with Association class Example: Enroll. This is an Association class which links 2 more classes together and it doesnot exist on its own.. meaning Enroll class need a course and a student to link

Draw classes as boxes

    1        *

Person ---------- Address

One peson is linked multiple address 1..2 (one or 2 person )

Generalisation (Parent = Child)

Person <---------Student <---------Professor

Professor teaching course

      1..*                  *   

Professor ------------------------> Course

A professor might teach a course or might not teach a course so put

  • in a course side...

have system to be more flexible, scalable...

This is an Association class which links 2 more classes together and it doesnot exist on its own.. meaning Enroll class need a course and a student to link...

Think about multiplicity - a student can enroll in one course or multiple courses..

Student * -------------- 0..6 Course

A course can have 0 or more student so put * in student side. A student can enroll in 0 and upto 6 couses so put 0..6 in Course side.

Enroll (has date and grade - this tells when a student is enrolled in course and grade he got)

Professor update grade of a student, professor has association with couse, course has association with enroll and enroll has association with all students.

If i have to update a grade of a student -

In this way professor look at a course and look at all students enrolled in the course and go into Enroll class to modify the grade. This way professor need not look into personal details of all students but use associated Enroll class to just update the grade.

Association

https://www.dariawan.com/tutorials/java/association-aggregation-and-composition-in-java/

Association is a relationship between two separate classes that establishes through their objects. Each objects have their own life-cycle and there is no owner. Association can be one-to-one, one-to-many, many-to-one, many-to-many.

The association relationship indicates that a class knows about another class. It can be described as a “has-a” relationship between classes. The relationship between the classes can be bi-directional.

https://data-flair.training/blogs/association-in-java/

Multiple Students can be enrolled in a course

class Student{

}

class course{

List listOfStudents = new ArrayList();

}

A student enrolling in multiple courses

class Student {

List listOfCourse = new ArrayList();

}

Aggregation

Aggregation is a specialized form of Association where all objects have their own life cycle, where the child can exist independently of the parent. Aggregation is also called a “Has-a” relationship.

Let's take an example of Supervisor and Subordinate. An employee (as a subordinate) can not belong to multiple supervisors, but if we delete the supervisor, the employee object (subordinate) will not be destroyed. We can think about it as a “has-a” relationship.

public class Employee {

private final String name;
private Employee supervisor;
private final List<Employee> subordinates = new ArrayList<>();

Composition

Composition is specialized form of Aggregation and we can call this as a “death” relationship. Child object does not have its life-cycle and if parent object is deleted, all child objects will also be deleted.

public enum EngineType { PETROL, DIESEL
}

public class Engine {

private final EngineType engineType; 

public EngineType getEngineType() {
    return engineType;
}

public Engine(EngineType engineType) {
    this.engineType = engineType;
}

}

public class Car {

private final String name;
private final Engine engine;

}

Composition.java

public class Composition {

public static void main(String[] args) {
    Car car1 = new Car("Peugeot 3008", new Engine(EngineType.PETROL));
    Car car2 = new Car("BMW X5 Diesel", new Engine(EngineType.DIESEL));
    
    car1.print();
    car2.print();
}

}

OOPS

https://www.youtube.com/watch?v=EKxJclTX8iM

Inheritance - acquiring properties and behaviour of an existing class without rewriting the code. allow to resue code.

Polymorphism - perform a task in multiple ways - consist of method overloading and overriding we write a method definition in interface and write implementation classes and each implemented method would perform different task.

An adult behaves differently in differnt place home, company,market

Method overloading (compile time polymorphism) - we know which method is going to get executed at compile time itself. Method overriding (run time polymorphism) - we know which mehtod is going to get executed at runtime only.

Abstraction - hide implementation and expose APIs for others to use (we dont know how car works but drive)

Encapsulation - wrap your data and behaviour.


Object Oriented Analysis and Dseign/Introduction to OOAD

https://www.youtube.com/watch?v=baCmxrIPRdc

**OOA - **

  1. Discovery process where one understands and models the requirements of the system as Objects.
  2. The requirements are organized as objects.

**OOD **

  1. Process of planning system of interacting objects for the purpose of solving a s/w problem.
  2. Designing systems using self-contained objects and object classes.

OOAD -

It is a s/w engineering approach which models the system as interacting objects. Each object represents a system entity which plays a vital role to build the system.

Steps

a. Define use case - list of actions or event steps defining the interaction between actor and system to achieve a goal. popular tool for requirement analysis.

b. Define Domain model - conceptual model which incorporates both data and behaviour. It gives very good information about the problem to solve. Used to understand the problem of a given statement.

c. Define interaction diagrams - describe type of interactions among different elements in the model. interation behaviour is represented by 2 diagrams know as sequence diagram and collaboration diagram.

d. Define design class diagrams - describe structure of system by showing system classes, their attributes operations or method and the relationship among the objects.


https://www.youtube.com/watch?v=4qThXT_88-8

Strategy or methodology

real world concepts can be modelled as objects

features of oops

class and object encap message passing abstraction inheritance polymorphism

Objects can be living or non living and we can model a system based on requirements and perspective Modelling of objects ie object modelling can be done based on requirements or perspective

Take a dog - perspective is if you are going to buy or sell a dog.

Take a person and you see him in different perspectives - bank customer, General, Employee,

Person in Bank Customer can have below attributes and functionalites

name, dob, account number amount

functionalites

-withdraw amount -deposit amount -create account

Person as general can have below attributes

name, dob height weight

funtionalites -walk -sleep -produce

Person as employee in org

name, date of joining dob, skills previous employmer

funtionalites -skills -task performed


https://www.youtube.com/watch?v=sGxgZxwuHzc

Software Design : More Creative than analysis

Problem Solving Activity.

Initial Requirements | | Gather data on the user request [ think and come up with requirement questions and Validate Design against requirement] | |
Analyse Requirement data [ Obtain answer to requirement questions and Validate Design against requirement] | |
high level design [ Obtain answer to requirement questions and Validate Design against requirement] | | Refine and document the design [ Obtain answer to requirement questions and Validate Design against requirement]

Get Requirements -- Understand the requirements -- Gather additional data /clarification on the requirements - Analyse requirment data - come up with high level design -- refine and documen the design. In each step think and come up with requirement questions and get clarified and as well validate design against requirement.

Conceptual design and Technical Design

2 types of diagrams drawn - Conceptual design and technical design.

Conceptual design - (What customer think about the design - Customer) - Structure Conceptual design gives answers to customer queries...

Conceptual designer (Customer) what they think ? - where will data come from? what will happen to data in system? how will system look to users (user friendly or not) - customer get answers to all these questions from us.

Technical Design - How - Technical Designer how they design?

describe h/w config,

s/w needs,

communication of system,

input and output of the system ,

Network Architecture

Technical design - define what we are going to implment

Overall the design should be Correct and Complete, understandable, right level, maintainable. Design should satisfy both the customers and developers.

To satisfy customer we need to satisfy conceptual design and to satisfy developer we need to follow technical design.

⚠️ **GitHub.com Fallback** ⚠️