java - How to write a single responsibility principle -


i have menu class. menu class provide links. each link has iconid , text.
class should create bitmap iconid?
if link class build bitmap violates srp.
if helper class build bitmap lazy class.
whats right?

public abstract class link {     private int iconid;     private string description;      /* getters */      public abstract void action(); } 

it depends on scope of design.

if link classes have same bitmap type image, might make sense place image resolving mechanism within abstract class itself.

if, on other hand, have different image types , formats, have delegate image resolution extending classes. instance, have public class gifimagelink extends link , class take care of resolving gif image type, in turn delegated other singleton class.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -