小编And*_*scu的帖子

Objective-C相当于C#中的"覆盖"

假设一个类Vehicle有一个名为"StartEngine"的方法,在我的子类中称为"Airplane",我想覆盖"StartEngine".如果我使用C#,我应该使用Airplane的StartEngine方法声明/定义中的"override"关键字.

我问的原因是,如果不是"StartEngine"我键入"startengine",C#会抱怨,但是由于该关键字,Objective-C不会.

objective-c

13
推荐指数
2
解决办法
1万
查看次数

上帝对象 - 减少与"主"对象的耦合

我有一个名为Parameters的对象,它跨越包边界从方法到方法向下和向上抛出调用树.它有大约五十个状态变量.每种方法可能使用一个或两个变量来控制其输出.

我认为这是一个坏主意,因为我不能轻易看到方法需要运行什么,甚至如果模块Y的某些参数组合与我当前的模块完全无关,可能会发生什么.

有什么好的技术可以减少与这个神对象的耦合,或者理想地消除它?

        public void ExporterExcelParFonds(ParametresExecution parametres)
    {
        ApplicationExcel appExcel = null;
        LogTool.Instance.ExceptionSoulevee = false;


        bool inclureReferences = parametres.inclureReferences;
        bool inclureBornes = parametres.inclureBornes;
        DateTime dateDebut = parametres.date;
        DateTime dateFin = parametres.dateFin;

        try
        {
            LogTool.Instance.AfficherMessage(Variables.msg_GenerationRapportPortefeuilleReference);

            bool fichiersPreparesAvecSucces = PreparerFichiers(parametres, Sections.exportExcelParFonds);
            if (!fichiersPreparesAvecSucces)
            {
                parametres.afficherRapportApresGeneration = false;
                LogTool.Instance.ExceptionSoulevee = true;
            }
            else
            {
Run Code Online (Sandbox Code Playgroud)

来电者会:

                PortefeuillesReference pr = new PortefeuillesReference();
            pr.ExporterExcelParFonds(parametres);
Run Code Online (Sandbox Code Playgroud)

oop refactoring god-object

8
推荐指数
1
解决办法
1583
查看次数

将数据加载到核心数据模式中

我正在实现一个基于导航的应用程序.用户将深入到感兴趣的节点.我正在使用Core Data,主要是因为我想尝试一下.如何最初加载数据库?我应该编写最初加载数据库的自定义代码,还是有一些工具可以帮我完成?

iphone core-data

7
推荐指数
2
解决办法
5826
查看次数

标签 统计

core-data ×1

god-object ×1

iphone ×1

objective-c ×1

oop ×1

refactoring ×1