MATLAB Answers

Advise on how to structure different classes. I'm OO newbie

1 view (last 30 days)
I have between 1 and 1500 oscilloscope traces that make up a 2D-dataset that is associated with a lot of other parameters (eg X, Y, Z-position, thickness, etc), so I thought that I would use a classes to structure it all. I want to perform different calculations on/based on the data like, spectral analysis and some other operations eg find peaks (or lines in the 2D image) automatically.
I've heard somewhere that it's bad to have a so-called god-object, so I thought I would separate the classes for storing the data from the class performing the spectral analysis etc. What is the best way to make the class that performs the spectral analysis access the data in the "Storage class"? Or should I make the spectral analysis inherit from the storage class? Or do I have it all wrong, maybe there's a much better way to set up my classes?
Thanks in advance/M

Accepted Answer

Adam
Adam on 8 Feb 2017
Don't have a calculator class inherit from a data class.
Either just give public access to what is in the data class, give access to specific classes e.g.
properties( SetAccess = private, GetAccess = ?SpectralAnalysisClass )
or if you wish you could have some generic function on your data class that allows you to pass in a function handle to act on the data. Then you can keep the data private, but it can get complicated if you have lots of properties and functions wanting to access different of them.
  5 Comments

Sign in to comment.

More Answers (0)

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by