SlideShare a Scribd company logo
SOLID OOPS
ConvertingReal world entities into programming Objects ;
  understanding its applications ; API designing, MVC framework
   We apologize for wrong session title 
   Lets know each other
   Your expectations
   Our aim
   Why should you join this session
   Goodies for active participants 




Introduction
 What is “Real”?
 Everything outside of your program is
  Real.
 Even your own program is a Real World
  Entity for some other program or even for
  your own program!
 In short




Real World Entity…
 Because these are all the “things” on
  which we want to work upon.
 Yes, and by work we do not mean, just
  writing the code! 




Why do we bother about this?
   Objects? Why?
   How are they introduced in the
    programming world?
   Where are they used often?
   State and behaviour
   Who should use it?




Correlating to programming
objects
 We separate our real world entities in
  different groups
 Object is an instance of a class


                       Ball



                    instances of




What is this class?
 How classes are organized?
 Why classes need to be organized?
 Is there any standard way to do it?
 If yes, whats it?




Organization
   How these different attributes of a class
    are defined?
   fields/properties - state
   methods/functions - behavior
   constructors/initializers
   destructors




What class contains?
 What is the object oriented way of getting
  rich ?
     — Inheritance
 Relations between the classes
 By the way, are you good at relations?




Relations
   Have you watched Television?




Interface
   Something you use to keep your stuff from
    mixing together
   Folders
   Drives
   A customized, more sophisticated package
   Examples familiar to you are,
    ◦ ZIP file
    ◦ EXE file
    ◦ DLL file etc.

Point is, keep your stuff organized.


Package
What is Abstraction?
•   Abstraction - a concept or idea not associated with
    any specific instance

•   It is all about perspective
Where does abstraction exist?
•   Control abstraction
    o   Abstraction of actions


•   Data abstraction
    o   Abstraction of information
How does this relate to
programming?
•   Writing functions/subroutines is control
    abstraction.
•   Datatypes is data abstraction.
Data Abstraction
•   Generalization
•   Specialization
Example
public class Animal extends
  LivingThing{                          theChicken = new Animal();
       private Location loc;              theCat = new Animal();if
       private double energyReserves;
                                          (theChicken.isHungry())
         public boolean isHungry() {      {
             return energyReserves <
  2.5;                                   theChicken.eat(grains);}
       }                                 if (theCat.isHungry()) {
       public void eat(Food f) {             theCat.eat(mouse);}
           // Consume food               theCat.moveTo(theSofa);
           energyReserves +=
  f.getCalories();
       }
       public void moveTo(Location l)
  {
           // Move to new location
           loc = l;
       }}
It's relevance with OOP
•   Object is an attempt to combine data and control
    abstraction
•   Polymorphism
•   Inheritence
Why do this?
•   Separate the business logic from the underlying
    complexity
•   Make it easier to parallelize tasks
•   Meaningful amount of details are exposed
•   Representation in a similar form in semantics
    (meaning) while hiding implementation details.
Why do we write programs?
We have the right objects in
place, now what?
•   Let's get them talking to each other
•   Let's actually tell them what to talk about
What sort of messages?
•   Creation
•   Invocation
•   Destruction
Who generates these
messages?
•   Aliens?           •   Platform
•   The Government?   •   User Interaction
                      •   Events
API Designing
String operations
                                         I need it to be
  Hehehe! The                             menu driven
 whole 2 hours I
 will just write a
  fancy menu




                     Programming Lab I
Set operations

 Again! *$%#@                        I need it to be
  Menu will be                        menu driven
   “Enter 1 to
  proceed 0 to
      exit”




                 Programming Lab I
Don’ts we do
 Monolithic programs
 Single file containing all functions
 Code repetition
 Thinking less about function signature
 Reinventing the wheel
What we think about API 




              API
What it actually is 
 printf(), scanf(), strcmp()


 Easy to use and hard to misuse                       Spec of DS,
                                                       functions,
 Can be programming language unspecific!!               behavior
                                                          etc.

 Not necessarily a code library, can be just a spec


 You can create your own API too
Lets design an API
Designing Process                       (based on suggestions by Joshua Bloch)


   Write 2 programs and not one
   Write API first

    ◦   Understand the use case
    ◦   Foresee future extensions (don’t change API often)
    ◦   A general purpose API vs multiple small API’s
    ◦   If you can’t name it, its doing either extra or doing less
    ◦   Don’t surprise the API user, don’t do extra
    ◦   Remember! You can always add but you can’t remove
    ◦   Document the API religiously!
    ◦   Use consistent parameter ordering.
    ◦   Extra params, use a struct

   Code more! API is living thing
   Expect to make mistakes. Refactor API!
   Encourage others to use it
MVC Architecture
Programming without MVC
                                I need it
   Linked List                 with GUI
    o   add a node
    o   remove a node
    o   reverse a linked list


 Linked list with GUI
 ______      ______    ______
|__1__| |__5__| |__7__| …
Challenges


 Data          Functions        GUI
 Structures    • Function       • Creating
 • struct ?      signature        boxes
 • Separate    • Flow control   • Moving
   variables                      boxes
Nightmare begins
typedef struct node{
          struct node* nextNode;
…
}Node;
…
Node *linkedlist;
addNewNode(){
         while (linkedlist->nextNode!=null){
                  drawSquare(); //you may have internal D.S. for each square
                  drawArrow();
         }

         Node *newNode = (Node*) malloc(sizeof(struct node));
         scanf(); // for new values
         newNode->val1 = …;
         newNode->val2 = …;
         linkedlist->nextNode = newNode;

         while (linkedlist->nextNode!=null){
                  drawSquare();
                  drawArrow();
         }
}
New requirements




 Keep different colors for each node
 I want oval nodes not rectangular nodes
 I want linked list nodes to be shown in
  hierarchy not in straight line.
                       Make Changes
FB Timeline: Full of GUI
Components
MVC Framework: Coding vs.
Architecting




                       Its nothing but
                       how you design
                       your code.
Model             View             Controller
• Handling data   • Display data   • Read data
• Save them on                       from view
  file or in                       • Control user
  internal D.S                       interaction
                                   • Send new
                                     data to model




Roles: Model, View and Controller
M-V-C not MVC
   Keep them separate
   You may create different files
    ◦   A separate “model.h”
    ◦   A separate “view.c” (includes model.h)
    ◦   A separate “controller.c” (includes model.h)
    ◦   Give deep thought to data structures


   Principle of Agnosticism:
    each component is unaware of others presence
Model
typedef struct node{                               C++ or other
   struct node* nextNode;
   int id;                                        OOP languages
   …                                              make finding the
}Node;
int globalId = 0;
                                                   context easy

typedef struct linkedList{
   Node * headNode;
   int id;
   int listLength;
}LinkedList;
LinkedList *linkedListPool[];

void addNode(int linkedListId, int index, Node *newNode){
   …
}
void removeNode(int linkedListId, Node *node){
   …
}

LinkedList* createNewLinkedList(){
   LinkedList* newll = (LinkedList*) malloc(sizeof(struct linkedList));
   newll->id = globalId++;
   newll->headNode = (Node*) malloc(sizeof(struct node));
   newll->length = 0;
   linkedListPool[globalId] = newll;
   return newll;
}
View
typedef struct viewNode{
       struct viewNode* nextViewNode;
       int xLocation, int yLocation;
       String color; //#FF3e2A (in hex)
…
}ViewNode;

//Similar to Model create another struct
typedef struct display{
  ViewNode* head;
  int id;
  int length;
}Display;
Display *displayNodeList[];
void addDisplayNode(int viewNodeId, int index, Node *newNode){
       //create new ViewNode
       //Render UI
  …
}

//create new display node like Model
Controller
typedef enum input{
  ADD,REMOVE,GET_LENGTH…
}Input;

LinkedList* linkedList = createNewLinkedList();
Display* display = createNewDisplay();

//Show a fancy menu
Input input = read input from user;
switch(input){
      case ADD:
            Node* newNode = //malloc new node;
            addNode(linkedList->id,newNode);
            addDisplayNode(display->id,newNode);
            break;
}
Questions ?

More Related Content

What's hot

Future-proofing Your JavaScript Apps (Compact edition)
Future-proofing Your JavaScript Apps (Compact edition)Future-proofing Your JavaScript Apps (Compact edition)
Future-proofing Your JavaScript Apps (Compact edition)
Addy Osmani
 
Design patterns illustrated 010PHP
Design patterns illustrated 010PHPDesign patterns illustrated 010PHP
Design patterns illustrated 010PHP
Herman Peeren
 
Js: master prototypes
Js: master prototypesJs: master prototypes
Js: master prototypes
Barak Drechsler
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScript
Forziatech
 
JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript Objects
Hazem Hagrass
 
Jazoon 2010 - Building DSLs with Eclipse
Jazoon 2010 - Building DSLs with EclipseJazoon 2010 - Building DSLs with Eclipse
Jazoon 2010 - Building DSLs with Eclipse
Peter Friese
 
Scalable JavaScript Design Patterns
Scalable JavaScript Design PatternsScalable JavaScript Design Patterns
Scalable JavaScript Design Patterns
Addy Osmani
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
Sehwan Noh
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript Basics
Mindfire Solutions
 
iOS 101 - Xcode, Objective-C, iOS APIs
iOS 101 - Xcode, Objective-C, iOS APIsiOS 101 - Xcode, Objective-C, iOS APIs
iOS 101 - Xcode, Objective-C, iOS APIs
Subhransu Behera
 
Dependency Inversion and Dependency Injection in PHP
Dependency Inversion and Dependency Injection in PHPDependency Inversion and Dependency Injection in PHP
Dependency Inversion and Dependency Injection in PHPmtoppa
 
Design patterns in java script, jquery, angularjs
Design patterns in java script, jquery, angularjsDesign patterns in java script, jquery, angularjs
Design patterns in java script, jquery, angularjs
Ravi Bhadauria
 
JavaScript OOPS Implimentation
JavaScript OOPS ImplimentationJavaScript OOPS Implimentation
JavaScript OOPS Implimentation
Usman Mehmood
 
JavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayJavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayChamnap Chhorn
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
Sujith Kumar
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
Fu Cheng
 
Scalable JavaScript Application Architecture
Scalable JavaScript Application ArchitectureScalable JavaScript Application Architecture
Scalable JavaScript Application Architecture
Nicholas Zakas
 

What's hot (20)

Future-proofing Your JavaScript Apps (Compact edition)
Future-proofing Your JavaScript Apps (Compact edition)Future-proofing Your JavaScript Apps (Compact edition)
Future-proofing Your JavaScript Apps (Compact edition)
 
Design patterns illustrated 010PHP
Design patterns illustrated 010PHPDesign patterns illustrated 010PHP
Design patterns illustrated 010PHP
 
Js: master prototypes
Js: master prototypesJs: master prototypes
Js: master prototypes
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScript
 
Iphone course 1
Iphone course 1Iphone course 1
Iphone course 1
 
JavaScript Objects
JavaScript ObjectsJavaScript Objects
JavaScript Objects
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
Jazoon 2010 - Building DSLs with Eclipse
Jazoon 2010 - Building DSLs with EclipseJazoon 2010 - Building DSLs with Eclipse
Jazoon 2010 - Building DSLs with Eclipse
 
Scalable JavaScript Design Patterns
Scalable JavaScript Design PatternsScalable JavaScript Design Patterns
Scalable JavaScript Design Patterns
 
Week3
Week3Week3
Week3
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript Basics
 
iOS 101 - Xcode, Objective-C, iOS APIs
iOS 101 - Xcode, Objective-C, iOS APIsiOS 101 - Xcode, Objective-C, iOS APIs
iOS 101 - Xcode, Objective-C, iOS APIs
 
Dependency Inversion and Dependency Injection in PHP
Dependency Inversion and Dependency Injection in PHPDependency Inversion and Dependency Injection in PHP
Dependency Inversion and Dependency Injection in PHP
 
Design patterns in java script, jquery, angularjs
Design patterns in java script, jquery, angularjsDesign patterns in java script, jquery, angularjs
Design patterns in java script, jquery, angularjs
 
JavaScript OOPS Implimentation
JavaScript OOPS ImplimentationJavaScript OOPS Implimentation
JavaScript OOPS Implimentation
 
JavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayJavaScript in Object-Oriented Way
JavaScript in Object-Oriented Way
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
Scalable JavaScript Application Architecture
Scalable JavaScript Application ArchitectureScalable JavaScript Application Architecture
Scalable JavaScript Application Architecture
 

Viewers also liked

Livingston eric visual_resumestoryboard
Livingston eric visual_resumestoryboardLivingston eric visual_resumestoryboard
Livingston eric visual_resumestoryboardAiric Livingston
 
NoSQL
NoSQLNoSQL
Livingston eric visual_resumestoryboard
Livingston eric visual_resumestoryboardLivingston eric visual_resumestoryboard
Livingston eric visual_resumestoryboardAiric Livingston
 
Livingston eric visual_resumestoryboard
Livingston eric visual_resumestoryboardLivingston eric visual_resumestoryboard
Livingston eric visual_resumestoryboardAiric Livingston
 
Livingston eric visual_resumestoryboard
Livingston eric visual_resumestoryboardLivingston eric visual_resumestoryboard
Livingston eric visual_resumestoryboardAiric Livingston
 

Viewers also liked (6)

Livingston eric visual_resumestoryboard
Livingston eric visual_resumestoryboardLivingston eric visual_resumestoryboard
Livingston eric visual_resumestoryboard
 
NoSQL
NoSQLNoSQL
NoSQL
 
Livingston eric visual_resumestoryboard
Livingston eric visual_resumestoryboardLivingston eric visual_resumestoryboard
Livingston eric visual_resumestoryboard
 
Livingston eric visual_resumestoryboard
Livingston eric visual_resumestoryboardLivingston eric visual_resumestoryboard
Livingston eric visual_resumestoryboard
 
Passives
PassivesPassives
Passives
 
Livingston eric visual_resumestoryboard
Livingston eric visual_resumestoryboardLivingston eric visual_resumestoryboard
Livingston eric visual_resumestoryboard
 

Similar to OOP, API Design and MVP

Tell Me Quando - Implementing Feature Flags
Tell Me Quando - Implementing Feature FlagsTell Me Quando - Implementing Feature Flags
Tell Me Quando - Implementing Feature Flags
Jorge Ortiz
 
Dependency injection Drupal Camp Wrocław 2014
Dependency injection Drupal Camp Wrocław 2014Dependency injection Drupal Camp Wrocław 2014
Dependency injection Drupal Camp Wrocław 2014
Greg Szczotka
 
Robots in Swift
Robots in SwiftRobots in Swift
Robots in Swift
Janie Clayton
 
Jump Start To Ooad And Design Patterns
Jump Start To Ooad And Design PatternsJump Start To Ooad And Design Patterns
Jump Start To Ooad And Design Patterns
Lalit Kale
 
Jump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design PatternJump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design Pattern
Nishith Shukla
 
AngularConf2015
AngularConf2015AngularConf2015
AngularConf2015
Alessandro Giorgetti
 
The advantage of developing with TypeScript
The advantage of developing with TypeScript The advantage of developing with TypeScript
The advantage of developing with TypeScript
Corley S.r.l.
 
Dependency Injection and Autofac
Dependency Injection and AutofacDependency Injection and Autofac
Dependency Injection and Autofac
meghantaylor
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
David McCarter
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
Maarten Balliauw
 
Thinking In Swift
Thinking In SwiftThinking In Swift
Thinking In Swift
Janie Clayton
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
David McCarter
 
Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)
Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)
Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)
Ovidiu Farauanu
 
Content Staging in Drupal 8
Content Staging in Drupal 8Content Staging in Drupal 8
Content Staging in Drupal 8
Dick Olsson
 
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
Maarten Balliauw
 
Design Patterns in Cocoa Touch
Design Patterns in Cocoa TouchDesign Patterns in Cocoa Touch
Design Patterns in Cocoa Touch
Eliah Nikans
 
Effective Scala: Programming Patterns
Effective Scala: Programming PatternsEffective Scala: Programming Patterns
Effective Scala: Programming PatternsVasil Remeniuk
 
Exciting JavaScript - Part I
Exciting JavaScript - Part IExciting JavaScript - Part I
Exciting JavaScript - Part I
Eugene Lazutkin
 
Javascript Best Practices
Javascript Best PracticesJavascript Best Practices
Javascript Best Practices
Christian Heilmann
 

Similar to OOP, API Design and MVP (20)

Tell Me Quando - Implementing Feature Flags
Tell Me Quando - Implementing Feature FlagsTell Me Quando - Implementing Feature Flags
Tell Me Quando - Implementing Feature Flags
 
Dependency injection Drupal Camp Wrocław 2014
Dependency injection Drupal Camp Wrocław 2014Dependency injection Drupal Camp Wrocław 2014
Dependency injection Drupal Camp Wrocław 2014
 
Robots in Swift
Robots in SwiftRobots in Swift
Robots in Swift
 
Jump Start To Ooad And Design Patterns
Jump Start To Ooad And Design PatternsJump Start To Ooad And Design Patterns
Jump Start To Ooad And Design Patterns
 
Jump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design PatternJump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design Pattern
 
AngularConf2015
AngularConf2015AngularConf2015
AngularConf2015
 
The advantage of developing with TypeScript
The advantage of developing with TypeScript The advantage of developing with TypeScript
The advantage of developing with TypeScript
 
Dependency Injection and Autofac
Dependency Injection and AutofacDependency Injection and Autofac
Dependency Injection and Autofac
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
 
Thinking In Swift
Thinking In SwiftThinking In Swift
Thinking In Swift
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
 
Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)
Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)
Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)
 
AngularJS - TechTalk 3/2/2014
AngularJS - TechTalk 3/2/2014AngularJS - TechTalk 3/2/2014
AngularJS - TechTalk 3/2/2014
 
Content Staging in Drupal 8
Content Staging in Drupal 8Content Staging in Drupal 8
Content Staging in Drupal 8
 
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
 
Design Patterns in Cocoa Touch
Design Patterns in Cocoa TouchDesign Patterns in Cocoa Touch
Design Patterns in Cocoa Touch
 
Effective Scala: Programming Patterns
Effective Scala: Programming PatternsEffective Scala: Programming Patterns
Effective Scala: Programming Patterns
 
Exciting JavaScript - Part I
Exciting JavaScript - Part IExciting JavaScript - Part I
Exciting JavaScript - Part I
 
Javascript Best Practices
Javascript Best PracticesJavascript Best Practices
Javascript Best Practices
 

Recently uploaded

UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 

Recently uploaded (20)

UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 

OOP, API Design and MVP

  • 1. SOLID OOPS ConvertingReal world entities into programming Objects ; understanding its applications ; API designing, MVC framework
  • 2. We apologize for wrong session title   Lets know each other  Your expectations  Our aim  Why should you join this session  Goodies for active participants  Introduction
  • 3.  What is “Real”?  Everything outside of your program is Real.  Even your own program is a Real World Entity for some other program or even for your own program!  In short Real World Entity…
  • 4.  Because these are all the “things” on which we want to work upon.  Yes, and by work we do not mean, just writing the code!  Why do we bother about this?
  • 5. Objects? Why?  How are they introduced in the programming world?  Where are they used often?  State and behaviour  Who should use it? Correlating to programming objects
  • 6.  We separate our real world entities in different groups  Object is an instance of a class Ball instances of What is this class?
  • 7.  How classes are organized?  Why classes need to be organized?  Is there any standard way to do it?  If yes, whats it? Organization
  • 8. How these different attributes of a class are defined?  fields/properties - state  methods/functions - behavior  constructors/initializers  destructors What class contains?
  • 9.  What is the object oriented way of getting rich ? — Inheritance  Relations between the classes  By the way, are you good at relations? Relations
  • 10. Have you watched Television? Interface
  • 11. Something you use to keep your stuff from mixing together  Folders  Drives  A customized, more sophisticated package  Examples familiar to you are, ◦ ZIP file ◦ EXE file ◦ DLL file etc. Point is, keep your stuff organized. Package
  • 12. What is Abstraction? • Abstraction - a concept or idea not associated with any specific instance • It is all about perspective
  • 13. Where does abstraction exist? • Control abstraction o Abstraction of actions • Data abstraction o Abstraction of information
  • 14. How does this relate to programming? • Writing functions/subroutines is control abstraction. • Datatypes is data abstraction.
  • 15. Data Abstraction • Generalization • Specialization
  • 16. Example public class Animal extends LivingThing{ theChicken = new Animal(); private Location loc; theCat = new Animal();if private double energyReserves; (theChicken.isHungry()) public boolean isHungry() { { return energyReserves < 2.5; theChicken.eat(grains);} } if (theCat.isHungry()) { public void eat(Food f) { theCat.eat(mouse);} // Consume food theCat.moveTo(theSofa); energyReserves += f.getCalories(); } public void moveTo(Location l) { // Move to new location loc = l; }}
  • 17. It's relevance with OOP • Object is an attempt to combine data and control abstraction • Polymorphism • Inheritence
  • 18. Why do this? • Separate the business logic from the underlying complexity • Make it easier to parallelize tasks • Meaningful amount of details are exposed • Representation in a similar form in semantics (meaning) while hiding implementation details.
  • 19. Why do we write programs?
  • 20. We have the right objects in place, now what? • Let's get them talking to each other • Let's actually tell them what to talk about
  • 21. What sort of messages? • Creation • Invocation • Destruction
  • 22. Who generates these messages? • Aliens? • Platform • The Government? • User Interaction • Events
  • 24. String operations I need it to be Hehehe! The menu driven whole 2 hours I will just write a fancy menu Programming Lab I
  • 25. Set operations Again! *$%#@ I need it to be Menu will be menu driven “Enter 1 to proceed 0 to exit” Programming Lab I
  • 26. Don’ts we do Monolithic programs Single file containing all functions Code repetition Thinking less about function signature Reinventing the wheel
  • 27. What we think about API  API
  • 28. What it actually is  printf(), scanf(), strcmp() Easy to use and hard to misuse Spec of DS, functions, Can be programming language unspecific!! behavior etc. Not necessarily a code library, can be just a spec You can create your own API too
  • 30. Designing Process (based on suggestions by Joshua Bloch)  Write 2 programs and not one  Write API first ◦ Understand the use case ◦ Foresee future extensions (don’t change API often) ◦ A general purpose API vs multiple small API’s ◦ If you can’t name it, its doing either extra or doing less ◦ Don’t surprise the API user, don’t do extra ◦ Remember! You can always add but you can’t remove ◦ Document the API religiously! ◦ Use consistent parameter ordering. ◦ Extra params, use a struct  Code more! API is living thing  Expect to make mistakes. Refactor API!  Encourage others to use it
  • 32. Programming without MVC I need it  Linked List with GUI o add a node o remove a node o reverse a linked list  Linked list with GUI ______ ______ ______ |__1__| |__5__| |__7__| …
  • 33. Challenges Data Functions GUI Structures • Function • Creating • struct ? signature boxes • Separate • Flow control • Moving variables boxes
  • 34. Nightmare begins typedef struct node{ struct node* nextNode; … }Node; … Node *linkedlist; addNewNode(){ while (linkedlist->nextNode!=null){ drawSquare(); //you may have internal D.S. for each square drawArrow(); } Node *newNode = (Node*) malloc(sizeof(struct node)); scanf(); // for new values newNode->val1 = …; newNode->val2 = …; linkedlist->nextNode = newNode; while (linkedlist->nextNode!=null){ drawSquare(); drawArrow(); } }
  • 35. New requirements  Keep different colors for each node  I want oval nodes not rectangular nodes  I want linked list nodes to be shown in hierarchy not in straight line. Make Changes
  • 36. FB Timeline: Full of GUI Components
  • 37. MVC Framework: Coding vs. Architecting Its nothing but how you design your code.
  • 38. Model View Controller • Handling data • Display data • Read data • Save them on from view file or in • Control user internal D.S interaction • Send new data to model Roles: Model, View and Controller
  • 39. M-V-C not MVC  Keep them separate  You may create different files ◦ A separate “model.h” ◦ A separate “view.c” (includes model.h) ◦ A separate “controller.c” (includes model.h) ◦ Give deep thought to data structures  Principle of Agnosticism: each component is unaware of others presence
  • 40. Model typedef struct node{ C++ or other struct node* nextNode; int id; OOP languages … make finding the }Node; int globalId = 0; context easy typedef struct linkedList{ Node * headNode; int id; int listLength; }LinkedList; LinkedList *linkedListPool[]; void addNode(int linkedListId, int index, Node *newNode){ … } void removeNode(int linkedListId, Node *node){ … } LinkedList* createNewLinkedList(){ LinkedList* newll = (LinkedList*) malloc(sizeof(struct linkedList)); newll->id = globalId++; newll->headNode = (Node*) malloc(sizeof(struct node)); newll->length = 0; linkedListPool[globalId] = newll; return newll; }
  • 41. View typedef struct viewNode{ struct viewNode* nextViewNode; int xLocation, int yLocation; String color; //#FF3e2A (in hex) … }ViewNode; //Similar to Model create another struct typedef struct display{ ViewNode* head; int id; int length; }Display; Display *displayNodeList[]; void addDisplayNode(int viewNodeId, int index, Node *newNode){ //create new ViewNode //Render UI … } //create new display node like Model
  • 42. Controller typedef enum input{ ADD,REMOVE,GET_LENGTH… }Input; LinkedList* linkedList = createNewLinkedList(); Display* display = createNewDisplay(); //Show a fancy menu Input input = read input from user; switch(input){ case ADD: Node* newNode = //malloc new node; addNode(linkedList->id,newNode); addDisplayNode(display->id,newNode); break; }