Giter VIP home page Giter VIP logo

design-patterns's Introduction

Hey there I'm Tanmay

version :26.12.2021   profile count  GitHub kanmaytacker  build: passing

👨🏻‍💻  About Me

💡  I'm a Computer Science and ML Engineer who has spent 8+ years building scalable distributed systems, optimisation engines and low latency financial systems. These days I just wrangle LLMs. 🤖
🎓  I'm an alumnus of NIT Allahabad. A proud Moti ka lal :D
🎓  My most recent academic misadventure was as postgraduate student studying Artificial Intelligence at the School of Aerospace at Cranfield University.
🛠  My last work project was building NodeIQ at Locus.sh. I have previously worked for Practo.
🌱  The brain fascinates me and you had me at Computational Neuroscience.
🌱  The space is where we are headed, and that just might save us from impending doom.
✉️  If you need a consultation on your project, you can reach me at [email protected].
✉️  If you want to say Hi, you can email me at [email protected].

📚 Latest publications

🔧 Latest work

✍ Latest posts

📖   Reading list

🔧 Technologies & Tools

📫   How to reach me:

Work   Gmail  

If you like what I do

Buy Me Chai

design-patterns's People

Contributors

kanmaytacker avatar sanketh221 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

design-patterns's Issues

implementation of builder pattern in typescript

Hi,
implementation of builder pattern in TS looks like -

export class Student {
name: String;
age: Number;

constructor(studentBuilder: StudentBuilder) {
    this.name = studentBuilder.name;
    this.age = studentBuilder.age;
}

}

export class StudentBuilder {
private _name: String = "";
private _age: Number = 0;

constructor(){
    
}

setName(name: String) {
    this._name = name
    return this
}

setAge(age: Number) {
    this._age = age
    return this
}

get name(): String {
    return this._name
}

get age(): Number {
    return this._age
}

build() {
    return new Student(this);
}

}

==================================================
client code:
const student = new StudentBuilder().setName("vijay").setAge(29).build()

======================================================

but in java it is some what different.

or there is better way to implementing it.

Netflix Assignment

Exercise

Design the class Diagram and database Schema for a system like Netflix with following Use Cases.

  • Netflix has users.
  • Every user has an email and a password.
  • Users can create profiles to have separate independent environments.
  • Each profile has a name and a type. Type can be KID or ADULT.
  • There are multiple videos on netflix.
  • For each video, there will be a title, description and a cast.
  • A cast is a list of actors who were a part of the video. For each actor we need to know their name and list of videos they were a part of.
  • For every video, for any profile who watched that video, we need to know the status (COMPLETED/ IN PROGRESS).
  • For every profile for whom a video is in progress, we want to know their last watch timestamp.

Solution

Class Diagram

classDiagram
    direction LR
    class User {
        +String name
        +String email
        -String password
        -String phone
        +getName() String
        +getEmail() String
        +getPhone() String
    }
    
    class Profile {
        +User user
        +ProfileType type
        +String name
        +Video[] videos
        +getVideoStatus(Video) : String
        +getVideoProgress(Video) : Datetime
    }

    class ProfileType {
        <<enumeration>>
        KID
        ADULT
    }

    Profile "*"-->"1" ProfileType
    User "1"*--"*" Profile : has

    class VideoStatus{
        <<enumeration>>
        COMPLETED
        IN_PROGRESS
        RECOMMENDED
    }

    class Video {
        +String title
        +String description
        +Actor[] cast
    }
    
    class Actor {
        +String name
    }

    Profile "1" --o "*" Video
    Video "*"--o"*" Actor


    

ER Diagram

erDiagram
    USER {
        int id PK
        varchar name
        varchar email
        varchar password
        varchar phone
    }

    PROFILE {
        int id PK
        varchar name
        enum type
        int user_id FK
    }

    USER ||--|{ PROFILE : creates
    
    VIDEO {
        int id PK
        varchar title
        varchar description
    }
    ACTOR {
        int id PK
        varchar name
    }
    CAST {
        int id PK
        int video_id FK
        int actor_id FK
    }

    PROFILE_VIDEO {
        int id PK
        int profile_id FK
        int video_id FK
    }

    PROFILE ||--o{ PROFILE_VIDEO : has
    VIDEO ||--o{ PROFILE_VIDEO : has
    VIDEO ||--|{ CAST : has
    ACTOR ||--|{ CAST : part_of


Prototype Design Pattern

In the sample code of Prototype Design pattern, the User class is declared as an abstract class but just below that it's been instantiated with the new keyword which is a syntax error in Java as objects of Abstract classes can't be created.

Netflix Assigment

Take Home Exercise

Design the class Diagram and database Schema for a system like Netflix with following Use Cases.

  • Netflix has users.
  • Every user has an email and a password.
  • Users can create profiles to have separate independent environments.
  • Each profile has a name and a type. Type can be KID or ADULT.
  • There are multiple videos on netflix.
  • For each video, there will be a title, description and a cast.
  • A cast is a list of actors who were a part of the video. For each actor we need to know their name and list of videos they were a part of.
  • For every video, for any profile who watched that video, we need to know the status (COMPLETED/ IN PROGRESS).
  • For every profile for whom a video is in progress, we want to know their last watch timestamp.

MY SOLUTION

NETFLIX

Class Diagram

classDiagram
direction TB
    class User {
        -String email
        -String password
    }
    
    class Profile {
        -User user
        -String name
        -ProfileType type
        -Video[] videos
    }
    
    class ProfileType {
        <<enumeration>>
        ADULT
        KID
    }
    
    class VideoStatus {
        <<enumeration>>
        COMPLETED
        IN_PROGRESS
    }
    
    class Video {
        -String title
        -String descripiton
        -Actor[] cast
    }
    
    class Actor {
        -String name
    }
    
    class ProfileVideo {
        Profile profile
        Video video
        VideoStatus status
        DateTime timeStamp
    }
    
    User "1" *-- "*" Profile
    Actor "*" o-- "*" Video
    Video "*" o-- "*" Profile
    Profile *-- ProfileVideo
    Video *-- ProfileVideo
erDiagram
    USER {
        int id PK
        String email
        String passoword
    }
    
    PROFILE {
        int id PK
        String type
        int user_id FK
    }
    
    ACTOR {
        int id PK
        String name
    }
    
    VIDEO {
        int id PK
        String title
        String description
    }
    
    ACTOR_VIDEO {
        int actor_id FK "Composite PK"
        int video_id FK "Composite PK"
    }
    
    VIDEOSTATUS {
        int id PK
        String name
    }
    
    PROFILE_VIDEO {
        int profile_id FK "Composte PK"
        int video_id FK "Composite PK"
        int video_status_id FK
        DateTime timestamp 
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.