> I have a question with regards to program design.
>
[quoted text clipped - 50 lines]
>
> Thanks

Signature
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
m97rek wrote:
>> If I have a class that looks something like:
>>
[quoted text clipped - 7 lines]
>> //Call metod1
>> Method1(x);
You don't show us any method "Method1(int)". What is that method?
>> }
>>
[quoted text clipped - 13 lines]
>> Let's say now that I want to move method1 to another class/file in
>> order to keep the code as neat and tidy as possible.
That's not an engineering reason. Methods go with the class whose behavior
they implement.
>> How should I do that? What is best practice according to you? Should
>> the methods there be static?
Static methods are for class-wide behaviors. It's not about making things
"neat and tidy". If a behavior belongs to the whole class, as with utility
classes or factory methods, then make the method static, otherwise make it
instance-level. If you're not sure, and the class is instantiable, make it an
instance method.
Methods reflect your object model. If your model says that there is a
business object type "Foo", and that Foo thingies do certain behaviors, then
you implement that with a class Foo and methods in that class implement those
behaviors (preferring instance level over static where feasible).
>> I tried to create:
>>
[quoted text clipped - 9 lines]
>> unless I pass the whole class along:
>> MyMethods(x, this)
Huh? You lost me on this point. What is Engine?
Since its name begins with an upper-case letter, it must be a class. Since
you invoke method2() (no arguments) via Engine, it must be a static method.
MyMethods(x, this) is a constructor, but you haven't shown us this constructor.
>> Is this correct?
No.
>> I hope you see what I'm getting at here.
No.
You really, really need to read and follow
<http://www.physci.org/codes/sscce.html>
Provide us with an SSCCE. If you can't compile the code then we can't either.
> Actually, static means it IS accessible by Engine.method2();
>
> Though in general an abundance of static methods suggest that your OO
> design has a flaw.

Signature
Lew