Helper classes... I think!

Using Delphi7Pro, we have a class which is rather large. We want to extract some of the functionality out of it into its own unit. Now, we could just create a function but that loses the object-orientedness of the software as a whole. We could create a new class and create an instance of it, with the variable defined in the interface section (ie global) - also not a good idea. Or we could simply use the class without creating an instance of it, as there are no member properties, only methods (dangerous? bad practice?). OR maybe there's a fourth way - and I'm thinking helper classes here, but I could be way off track!

This may not be relevant but it might help understand the problem:
I have a list of class A objects. Every second, each object performs a calculation against itself and each of the other items in the list in turn. That then returns a value based on that calculation. This calculation is several hundred lines of code (it's not just numbers, but decisions as well).

As already stated, I'm aware of different ways of doing this, just wanted advice or other suggestions really. It's a SIL2 project so sloppy programming is not tolerated.


Geoff M.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

the description is vague, but to do something like "helper classes", you can implement interfaces on your class to be able to inject other objects to it without tying it down to a specific class

basically sounds like what you need is refactoring (break the code in smaller chunks in specific funcions, or more classes according to the job that needs to be done)

remember that if your class (or any function) is doing too much work, that's a sign of a "code smell"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gmayoAuthor Commented:
Thanks. That was interesting reading. The only thing that really applies is the "too much code" situation. Apart from this particular chunk of logic, it's hard to see how else to break it down.

Hmmm, actually I see a way now. It's one step back to take two steps forward but perhaps it'll help. Basically I implement classes that are "owned" by the parent class, which perform certain operations. The owning class stores the object pointer and calls its methods as necessary.


Geoff M.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.