Skip to content

Instantly share code, notes, and snippets.

@jianminchen
Created December 20, 2017 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jianminchen/61251fabfe4b614635edec810a456d4b to your computer and use it in GitHub Desktop.
Save jianminchen/61251fabfe4b614635edec810a456d4b to your computer and use it in GitHub Desktop.
Object-oriented design - Object model - the peer did 20 minutes talk
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