Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Query in Designing a system of classes

 
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All,

I have got a query in the design I am currently working on.

Scenario in brief

1. To automate set of tasks, performed at different times of the day.
2. Things we need to consider -- A core system to perform the tasks, and a scheduler to invoke them appropriately.
3. Tasks vary in type, like parsing a log file, invoking a batch file etc.

When I try to design the core set of classes that would perform the underlying tasks, I can think of the following approach.
I very much want to fine-tune my designing experience, as I am just starting with it.

1. The tasks are different in nature. However, to represent all tasks as entities, we can have a common base class.
2. The base class can be an "abstract" Task.
3. All the tasks will be derived from this. It would mean "ParseLogFile IS-A Task", for an instance.
4. We can have an interface "Performable" and a method "performTask()" which can be implemented by the "concrete" tasks.

Kindly validate this, and help me fine-tune it. Also, to extend this, I want to include the following features

1. A TaskFactory -- that instantiates a type of task, depending on the input (which could be time here)
2. A scheduler to trigger the instantiated task.

Kindly throw light on how we can go about, achieving a good design. I know, the question may sound little abstract, but I solicit your inputs. Thanks in advance.
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To start, start to shift your mind into thinking about "objects" not classes. You want to design a system of objects.

You might want to study the source code for Apache Ant build tool, e.g. org.apache.tools.ant.Task
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're re-implementing Quartz?
 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you looked at java.util.Timer?
 
Ramaswamy Srinivasan
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

James Clarks wrote:To start, start to shift your mind into thinking about "objects" not classes. You want to design a system of objects.

You might want to study the source code for Apache Ant build tool, e.g. org.apache.tools.ant.Task



Thanks James -- however, could you kindly explain, in what way this perspective shift will help me?
 
Ramaswamy Srinivasan
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:You're re-implementing Quartz?



Thanks for your reply.

I am actually not implementing Quartz. I was considering using Quartz for the "scheduling" part of my mini-mini app.
However, I first wanted to get my design proper, that's why I posted here.
 
Ramaswamy Srinivasan
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kengkaj Sathianpantarit wrote:Have you looked at java.util.Timer?



Kengkaj,

Thanks for the input. I will look at it for the scheduling part of it. Would you have any specific pointers to the core class design?
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ramaswamy Srinivasan wrote:

Kengkaj Sathianpantarit wrote:Have you looked at java.util.Timer?



Kengkaj,

Thanks for the input. I will look at it for the scheduling part of it. Would you have any specific pointers to the core class design?


I'm not sure what you mean by core class design, you should have a look at java.util.Timer first. It provides the things you were thinking to implement out of the box.
 
Ramaswamy Srinivasan
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kengkaj Sathianpantarit wrote:

Ramaswamy Srinivasan wrote:

Kengkaj Sathianpantarit wrote:Have you looked at java.util.Timer?



Kengkaj,

Thanks for the input. I will look at it for the scheduling part of it. Would you have any specific pointers to the core class design?


I'm not sure what you mean by core class design, you should have a look at java.util.Timer first. It provides the things you were thinking to implement out of the box.



Thanks again, for your reply.

True -- Timer and TimerTask can do it out of the box, but I am trying to write some code of my own here -- this is for learning purpose, and not for my business purpose. I have already tried Timer and TimerTask for some other purpose. This time, I want to try doing it on my own. I can even use windows scheduler for the time based scheduling part, but how best we can get the tasks automated was my question.
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can have a look at source code of java.util.Timer if you want to learn.
 
If you want to look young and thin, hang around old, fat people. Or this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic