English 中文(简体)
一个大的班级,相比之下,在科恰马大学应用中有几个小班。
原标题:One large class compared to several small classes for a Cocoa Mac application

我利用ARC,创建了一项申请,将数据从网上XML档案中分类。 我能够拿到我所需要的一切,用一个类别,用一个字向APIC发出呼吁。 该表提供了XML数据。 由于大量Xml文件,我有许多变量,即IBOutlets和IBActions与这一类别有关。

但有两种做法:

1) create a class which parses the XML data and also implements that data for your application , i.e. create one class that does everything (as I have already done)

or

(2) 开设一门课,对XML数据进行分类,并设立其他班,处理从XML教区获得的数据,即一个班子做教,另一个班子则使用数据。

请注意,提供XML数据的某些预报器跟踪其服务的电话/分钟或电话/日数。 因此,你不希望有几类人使用该软件,最好向接收所需要全部数据的APIC申请。

因此,最好利用几个较小的班级处理xml数据,还是只使用一个大班子做什么?

最佳回答

如果存在疑问,小班就更好。

(2) 开设一门课,对XML数据进行分类,并设立其他班,处理从XML教区获得的数据,即一个班子做教,另一个班子则使用数据。

其中一个关键优势是,后一类模式与前一类工作分开。 这一点很重要:

  • As Peter Willsey said, when your XML parser changes. For example, if you switch from stream-based to document-based parsing, or vice versa, or if you switch from one parsing library to another.
  • When your XML input changes. If you want to add support for a new format or a new version of a format, or kill off support for an obsolete format, you can simply add/remove parsing classes; the model class can remain unchanged (or receive only small and obvious improvements to support new functionality in new/improved formats).
  • When you add support for non-XML inputs. For example, JSON, plists, keyed archives, or custom proprietary formats. Again, you can simply add/remove parsing classes; the model class need not change much, if at all.

即便这些事情从未发生,它们仍然比共同.好。 输入和模拟用户数据是两个不同的工作;加在一起,很难或不可能分开解释。 将它们分开,你可以改变,而不必走到另一边。

问题回答

我认为这取决于你的申请。 应考虑的是,如果你不得不改变你正在使用的XML Parser? 你必须重写一流,你可以打破许多不相关的功能。 如果你将XML教区评为“教区”,那只是重写这一特殊类别执行的问题。 或者,如果你的申请范围发生变化,你突然有几点看法? 您是否能够在别处重复使用法而不违反德国(德国)原则?

你们想要争取的是低 coup的 coup合和高度的凝聚力,意思是,班级不应当相互依赖,班级应该有明确的责任,有高度相关的方法。





相关问题
2 mysql instances in MAC

i recently switched to mac. first and foremost i installed xampp. then for django-python-mysql connectivity, i "somehow" ended up installing a seperate MySQL. now the seperate mysql installation is ...

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Controlling OSX windows

I m trying to control windows of a foreign OSX applications from my application. I d like to 1. move the windows on the screen 2. resize the windows on the screen 3. change the currently active window ...

Switching J2SE versions on Mac OS (SnowLeopard)

My current JDK on Mac OS (10.6) is set to 1.6 and I d like to switch to 1.5. A listing of /System/Library/Frameworks/JavaVM.framework/Versions/ shows: lrwxr-xr-x 1 root wheel 10 Nov 3 18:34 ...

Scrolling inside Vim in Mac s Terminal

I ve been googling around trying to figure out if it s possible to use my mouse wheel to scroll while inside Vim in Mac s Terminal, with no luck. It seems as if only X11 or iTerm support this. Before ...

export to MP3 from quicktime API

A question for Apple,QT programmers. Would like to know if it s possible to export a Movie object to MP3 using the QuickTime API. Preferably the ConvertMovieToFile function. I ve looked at ...

热门标签