General Design Question in Swift – decomposition

My iOS program talk to an eBike computer called Cycle Analyst (CA) through a Bluetooth emitter. The same emitter can be use with different CA each containing different firmware version. Once I am connected to a CA, I just talk to that one for the duration of the run.

 

In my app I have a model for the CA in one file called CADeviceModel. This model has many array that need to be set(init) differently according to the Firmware version of the CA I am connected to.

 

So far, I do this in the same file as the model in a big switch case but as I add support for different firmware version I find the code of the model get too big.

 

Should I keep this part outside the Model, if yes, what if the best way to separate the model from all those different firmware configuration. Should I use a strut, and or enum or both or something else.

 

Also, where I can learn about decomposing.

 

I understand the principe of creating mostly short method because it is easier to maintain and test, but is it the file separation other that M-V-C that sometime puzzle me.

 

I understand this will come with a lot’s of coding but maybe I could get help to jump start a little.

Powered by WPeMatico

You may also like...

Comments are closed.