Sharing variables and methods between classes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shockna1
    New Member
    • Apr 2010
    • 30

    Sharing variables and methods between classes

    I have recently come across a situation where various non-related class need to share variables and methods. The first thing that came to my mind was to make a static class with static variables and methods which works fine, but I was wondering if there was a more OO way of doing this. Thanks in advance!
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    I tend to use static methods for commonly used utility functions.
    I'm not sure about static variables though, these are almost global.
    A more OOP way I suppose would be an abstract class from which other classes inherit, but as the other classes are unrelated this doesn't seem logical.
    I am also intersted in any other solutions provided.

    Comment

    Working...