Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OO class design

 
Nicol Green
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys!

I have one more question about OO design. In my previous post "Class relations mass" I got great assistance from Pete Stein. Thank You Pete, once more for that. Here I have similar problem, and I don't know how to apply entirely suggested logic. I will appreciate help on this.

Now I have class View, where GUI is implemented.
I want to do caesar encryption, and a few more.
I was thinking to create Caesar class, Playfair, ..., Encryption class,
and View. Is this a good thinking, or do I need only Encryption class
and put all cipher implementations in that one ?
This is the Encryption class, but I am not sure how to define encryption, to
say so ? Could You, please, help me somehow ?



Thank You!
 
salvin francis
Bartender
Posts: 1280
10
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all with MVC archiectecture, i suggest the following:



As an Optimization you might want to make Encryption's methods static ..


Next as you say you might change the encryption scheme later,

To this I suggest two approaches,

Approach 1 : Encryption contains type encryption Login.




Approach 2: Decorator-based Pattern

will post this idea soon.....
 
salvin francis
Bartender
Posts: 1280
10
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Approach 2 : Decorator-based Pattern



code can be written as :


This is not purely the decorator pattern though
 
Nicol Green
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You very much for your help, Salvin!

Maybe I like a bit more second approach.
I will go with it!

This is not purely the decorator pattern though


Sorry, this is new concept for me. I google it, but haven't find much.
Could You, please, give me a short explanation of it ? After that I suppose
I will see why this is not a "purely decorator pattern".Thanks!
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
salvin francis wrote:As an Optimization you might want to make Encryption's methods static.

Whereas I would suggest you don't, since static methods can make testing more difficult, and any "optimization" you get is minimal at best.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic