Created
December 20, 2017 07:40
-
-
Save jianminchen/61251fabfe4b614635edec810a456d4b to your computer and use it in GitHub Desktop.
Object-oriented design - Object model - the peer did 20 minutes talk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Let's say we're developing a vector graphics application. It will allow the user to create lines, rectangles, circles, text, etc. and manipulate them independently - move them, re-size them, etc. Design an object model for this application. | |
• How would you model the representation of the document in an object oriented language? | |
• What classes would you define? | |
• What methods would you have? What would your API look like? | |
Class: | |
- User | |
- Graph parent class, method, move, resize,...etc | |
- Subclasses: rectangles, circles, squares,... | |
Methods: | |
- User | |
List<Graph> lis; | |
create(Graph g) { | |
g.create(); | |
lis.add(g); | |
} | |
move(Graph g) { | |
g.move(); | |
} | |
resize(Graph g) { | |
g.resize(); | |
} | |
- Graph { (abstract class or interface) | |
create(); | |
move(); | |
resize(); | |
} | |
- Circles() implements Graph { | |
create() { | |
} | |
move() { | |
} | |
resize() { | |
} | |
} | |
API: REST API design | |
//RPC vs REST | |
// RPC : POST /createCircles body {id:, radius,..} | |
// GET /getCircles | |
// REST: POST /circles/{id} {radus:...} | |
// GET /circles/{id} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment