Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. SOLID principle problem

SOLID principle problem

Scheduled Pinned Locked Moved Java
questionhelpwpfdesignxml
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Neo10101
    wrote on last edited by
    #1

    I'm stuck with applying the SOLID principle in my code. Problems: 1) I don't want to violate SRP, so I don't know if the protected members of AbstractScreen are violating this 2) My screen interface should not have this many responsibilities, I probably need to remove them 3) I decided to make a DocumentLoader class to take care of providing my screens with the input and output documents they need in order to display something on the screen. What is displayed depends on the input and output file I give it. Thus I made the DocumentLoaderInterface, with loadDocuments(List). This is my real problem: where am I going to put the implementation of loadDocuments() if it varies per screen? I can't posssibly go put this code in a screen, because that will give the screen too many responsibilities. If I implement it in the DocumentLoader class, then only one implementation will be available, unless I make several DocumentLoader objects. Where do I instantiate them? If I call documentLoader.loadDocuments(); then where is the implementation going to be? How do I implement this?.. I'm really stuck. Please find below my code structure: package screens: Screen AbstractScreen

    protected Document inputDocument, outputDocument;
    protected SAXBuilder parser;
    protected ComponentService componentService;
    protected DocumentLoader documentLoader;

    ScreenInterface:

    public Document getScherm();
    public void addComponents();
    public Object getC(String key);
    public void loadDocuments();

    package ui:

    TestUi

    package utils:

    ComponentService
    UtilityFactory

    package xmlio:

    DocumentLoader
    DocumentLoaderInterface
    XmlIo
    XmlIoInterface

    //Application Goal: Have a GUI draw a XAML screen depending on the input XML document. Different documents will produce different charts.

    N 1 Reply Last reply
    0
    • N Neo10101

      I'm stuck with applying the SOLID principle in my code. Problems: 1) I don't want to violate SRP, so I don't know if the protected members of AbstractScreen are violating this 2) My screen interface should not have this many responsibilities, I probably need to remove them 3) I decided to make a DocumentLoader class to take care of providing my screens with the input and output documents they need in order to display something on the screen. What is displayed depends on the input and output file I give it. Thus I made the DocumentLoaderInterface, with loadDocuments(List). This is my real problem: where am I going to put the implementation of loadDocuments() if it varies per screen? I can't posssibly go put this code in a screen, because that will give the screen too many responsibilities. If I implement it in the DocumentLoader class, then only one implementation will be available, unless I make several DocumentLoader objects. Where do I instantiate them? If I call documentLoader.loadDocuments(); then where is the implementation going to be? How do I implement this?.. I'm really stuck. Please find below my code structure: package screens: Screen AbstractScreen

      protected Document inputDocument, outputDocument;
      protected SAXBuilder parser;
      protected ComponentService componentService;
      protected DocumentLoader documentLoader;

      ScreenInterface:

      public Document getScherm();
      public void addComponents();
      public Object getC(String key);
      public void loadDocuments();

      package ui:

      TestUi

      package utils:

      ComponentService
      UtilityFactory

      package xmlio:

      DocumentLoader
      DocumentLoaderInterface
      XmlIo
      XmlIoInterface

      //Application Goal: Have a GUI draw a XAML screen depending on the input XML document. Different documents will produce different charts.

      N Offline
      N Offline
      Nagy Vilmos
      wrote on last edited by
      #2

      Working from the bottom up, you should implement all the data logic below the UI layer. Have a class that loads the document, it will know how to interpret the document and get the definitions out. Then have asingle UI class read the data to define itself. This allows different UI's to use the same data class and can make supporting multiple platforms - desktop, tablet, web - much easier as you only need to implement the UI once per UX variant.


      Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups