This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Design help needed

 
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I'm working on program which attempts to automate testing. So we have multi-step wizards in the application and I'm trying to design for them. This is what I've come up with so far.

MultiStepWizard.java


IFormFiller.java


AbstractMultiStepWizard.java


MyStepWizard.java



The idea being the implementing concrete classes (MyStepWizard) would be able to specify how many steps they have and what they would like to perform ( form filling in this case ) in each of the step. As you can see I've created a setup() method and returning a map of formFillers, this is piece I'm not liking and could go out of hand when there are many steps.

There would be a few other things I would add in the AbstractMultiStepWizard like to previousStep(), nextStep(), goToStep() ( to which i think i should pass a String, although that looks like a little brittle ). There might be validation errors at each step so I think form fillers would return a list of validation errors.

Please share your thoughts and thanks in advance.

Thanks
Srikkanth

 
Author and all-around good cowpoke
Posts: 13078
6
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.If this was my problem I would not be writing code at this point, but working out the Use Case Diagrams showing how users interact with the system. I would show these diagrams to potential users of the system, both clients and administrators - only if they said "yeah, thats what I want" would I proceed to code architecture.

2. In thinking about code architecture, I would start by trying to separate the Model - View - Controller aspects - MVC is frequently very helpful.

3. Design for testing each stage that can feasibly be tested separately - trying to create everything at one go leads to frustration.

4. Note that mock-ups of user interfaces (the View) would be useful to make sure you are doing what the clients really want.

Bill
 
Srikkanth Mohanasundaram
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi William,

Thanks for replying. As I mentioned I'm writing this program to perform test automation. JUnit test methods would invoke this



In fact the test method would pass on the Selenium driver object and the implementation would be in the MultiStepWizard classes.

Thanks
Srikkanth
 
Sheriff
Posts: 14740
245
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with everything that Bill said. In addition:

1. Sounds like you're trying to reinvent the wheel. What are your special use cases that can't be handled by one of the many tools available already?

2. See http://www.joelonsoftware.com/articles/Wrong.html for why you should avoid names like "IFormFiller" - scroll down to the section "I'm Hungary"

3. The fact that you're writing this code so that it can be called by JUnit doesn't exempt it from needing unit tests of its own.

4. To reiterate what Bill said: You can't write everything at one go and expect it to work. Large, complex systems that work are invariably grown from small, simple systems that work. This is true in nature and it's even more so with software.
 
Srikkanth Mohanasundaram
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Junilu,

Thanks for your inputs. I never meant to name that interface as IFormFiller ( good catch !), but the article was a good read : ) , and I also intend to test this code. I have a few questions though

1. Why do you think this is re-inventing the wheel ? I'm trying to use the PageObjects pattern to represent the services on my UI. AbstractMultiStepWizard represents a multi-step wizard on the UI.

2.

What are your special use cases that can't be handled by one of the many tools available already?


I'm not sure what do you mean by this. I'm using Selenium and may be a unit testing framework like TestNG.

3. The question I've is more specific on the implementation part on how a concrete multi-step wizard can configure it's steps and the actions it would perform in them.

Thanks
Srikkanth
 
Junilu Lacar
Sheriff
Posts: 14740
245
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Srikkanth Mohanasundaram wrote:
I'm working on program which attempts to automate testing.


This would normally be taken to mean that you're trying to create some kind of automated testing tool. Your intent would have been clearer if you had written "I'm trying to write some code based on the PageObjects pattern that will make it easier to test a multi-page wizard UI with Selenium."
 
Srikkanth Mohanasundaram
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This would normally be taken to mean that you're trying to create some kind of automated testing tool.


Oh no no no no.. : )
 
Junilu Lacar
Sheriff
Posts: 14740
245
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then I would say that you are generalizing too early. Write page objects that are specific to each step in your wizard UI and refactor when you see duplication in the different page objects. Patterns are easier to discern when you actually see them in code rather than through speculation.
 
Srikkanth Mohanasundaram
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's reasonable : )
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Patterns are easier to discern when you actually see them in code rather than through speculation.



Personally I find that is true ONLY when looking at other people's professional finished code.

Working out my own patterns is best accomplished with diagrams such as use cases - if speculation means considering and discarding unusable patterns before devoting any time to coding, then speculation is a great time saver.

Are you concentrating on the UI because you already have test "model" classes which can conduct a single test?

Bill
 
Junilu Lacar
Sheriff
Posts: 14740
245
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

William Brogden wrote:
Personally I find that is true ONLY when looking at other people's professional finished code.


It's a given that clean and well-factored makes it easier to see patterns. The number of entries in http://c2.com/cgi/wiki?RuleOfThree seems to suggest that it is not uncommon to let the duplicates/triplicates emerge in the code before you generalize. To each his own though.
 
Srikkanth Mohanasundaram
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bill,

Are you concentrating on the UI because you already have test "model" classes which can conduct a single test?



It's an Angular application and I'm trying to run tests against this application in a real browser.

if speculation means considering and discarding unusable patterns before devoting any time to coding, then speculation is a great time saver.



Exactly why i want to invest some time thinking about it. And also I would like to create a fairly decent code base at the start , so my team can follow suit.

Thanks
Srikkanth
 
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!