Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

patent10021

macrumors 68040
Original poster
Apr 23, 2004
3,552
834
Is SO Meta the place to ask those very general questions that always get down-voted on SO or is it easy to get down voted on Meta too?

I need to ask a lot of general how to questions for some particular projects first before I can ask for code specific solutions.

Just as an example for this post.

Meta: How would you approach changing your code which is currently written to read then display mock data to eventually receive and display live server data?

progresses to the more specific question...

StackOverFlow: How would I populate a WKInterfaceLabel with live weather data?
 
It sounds like you're asking a meta Meta question. Is there a Meta Meta SO place to ask them?

That may sound frivolous, but why not try starting on Meta, and see what happens. Try with a few questions first, as sort of "mock data" or "trial balloon".


Taking the specific example:

How would you approach changing your code which is currently written to read then display mock data to eventually receive and display live server data?
I would design the mock data supplier so it's either a class or protocol, and the main code that consumes the data uses only that interface to access the data. Then the live data supplier will be written to the same interface; either a subclass or a protocol implementation.

The key point to see here is that the interface between the main code and the data supplier is defined first, and is unvarying. As long as the interface meets all the needs of the consumer, and the supplier is sufficiently abstracted from the implementation, this design will work regardless of whether the consumer is a WKInterfaceLabel or the supplier is weather data.

I can tell you from experience that you'll have to go through several iterations of the interface before you get it right. You'll always leave out some needed feature, which you won't discover until you try using it in the data consumer classes. You may also start out by defining too many methods, properties, etc. and they don't get used, or are used infrequently. You may also end up making design changes so the eventual live data (a server) is more easily able to implement the interface. In other words, you make some concessions on pure abstraction because it simplifies the real implementation, and is a "don't-care" condition for the mock data.

Finally, I might not make the WKInterfaceLabel directly aware of its data source. There might be a coordinator level that manages multiple labels, and that's where the awareness of the data source resides. You didn't describe the intended design well enough to decide that or not, but it's worth considering if there are lots of labels that change together as a group.


The general question is a pretty ordinary object-oriented design question. The fundamental principles are abstraction and encapsulation.
 
Let me turn this inside out.

I usually write the data layer first, before the UI or presentation layer. I drive the data layer with unit tests until I believe that it works. So I have a working data provider that loads the live weather data. Then when I write the UI layer I don't have to mess with mock data. I just use the functional data provider.
 
  • Like
Reactions: chown33
Is SO Meta the place to ask those very general questions that always get down-voted on SO or is it easy to get down voted on Meta too?

I need to ask a lot of general how to questions for some particular projects first before I can ask for code specific solutions.

Just as an example for this post.

Meta: How would you approach changing your code which is currently written to read then display mock data to eventually receive and display live server data?

progresses to the more specific question...

StackOverFlow: How would I populate a WKInterfaceLabel with live weather data?

The short answer is: No. Meta is there to ask questions about the Stack Overflow itself. If you want to ask a more generic programming question try http://programmers.stackexchange.com/
 
You could ask your general questions here. If they get answered, you can discuss the answers until you think you have enough detail to ask another more specific question.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.