The Flags Over Objects anti-pattern occurs when behavior is written outside of an object by inspecting flags (such as status codes), rather than within the object itself.

This violates the Tell, Don’t Ask principle, and results in chatty interfaces and distribution of behavior that probably belongs within the object.

Working around this issue, one will often experience the Shotgun Surgery coding smell, in which many small changes to many files are required in order to make changes to the system.

There are many ways to address this anti-pattern.

In the worst cases, the State design pattern can effectively be used to bring all state-transition related behavior into the object, or at least into objects specifically constructed to handle the responsibility of state and state transitions.

Flags Over Objects的更多相关文章

  1. Makefile文件学习总结

    Makefile文件相当于是一种脚本编程语言,目的是实现自动化编译.编写makefile文件的过程中可以使用变量.控制结构和函数等一般编程语言的特性. Makefile文件的组成内容.makefile ...

  2. Object Pascal中文手册 经典教程

    Object Pascal 参考手册 (Ver 0.1)ezdelphi@hotmail.com OverviewOverview(概述)Using object pascal(使用 object p ...

  3. Tell Don’t Ask

    The Tell, Don’t Ask (TDA) principle suggests that it is better to issue an object a command do perfo ...

  4. Other Linker Flags到底是什么

    一.问题描述 在项目开发中用到百度地图,有时候在工程中会报“方法找不到”的错误(unrecognized selector sent to instance). 二.问题分析 首先,要说明一下Othe ...

  5. The Truth About .NET Objects And Sharing Them Between AppDomains

    From http://geekswithblogs.net/akraus1/archive/2012/07/25/150301.aspx I have written already some ti ...

  6. Using self-defined Parcelable objects during an Android AIDL RPC / IPC call

    Using self-defined Parcelable objects during an Android AIDL RPC / IPC call In my previous post “Usi ...

  7. 【转】关于Xcode的Other Linker Flags

    链接器 首先,要说明一下Other Linker Flags到底是用来干嘛的.说白了,就是ld命令除了默认参数外的其他参数.ld命令实现的是链接器的工作,详细说明可以在终端man ld查看. 如果有人 ...

  8. 关于Xcode的Other Linker Flags

    背景 在ios开发过程中,有时候会用到第三方的静态库(.a文件),然后导入后发现编译正常但运行时会出现selector not recognized的错误,从而导致app闪退.接着仔细阅读库文件的说明 ...

  9. 【Java】Objects 源码学习

    2017-02-10 by 安静的下雪天  http://www.cnblogs.com/quiet-snowy-day/p/6387321.html    本篇概要 Objects 与 Object ...

随机推荐

  1. thinkphp前台html格式化输出日期

    输出格式: {$time|strtotime|date="Y年m月d日",###} 格式说明: $time 是日期字符串,一般后台的时间是"Y-m-d H:i:s&quo ...

  2. Win8Metro(C#)数字图像处理--2.25二值图像距离变换

    原文:Win8Metro(C#)数字图像处理--2.25二值图像距离变换  [函数名称] 二值图像距离变换函数DistanceTransformProcess(WriteableBitmap sr ...

  3. Android零基础入门第5节:善用ADT Bundle,轻松邂逅女神

    原文:Android零基础入门第5节:善用ADT Bundle,轻松邂逅女神 在前几期中总结分享了Android的前世今生.Android 系统架构和应用组件那些事.带你一起来聊一聊Android开发 ...

  4. 实现dropdownList 无刷新

    <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptMana ...

  5. PRML Chapter2

    参考文献:PRML2 参数方法和非参数方法 机器学习上的方法分为参数方法(根据先验知识假定模型服从某种分布,然后利用训练集估计出模型参数,也就弄清楚了整个模型,例如感知器)和非参数方法(基于记忆训练集 ...

  6. 基于mipsel编译Qt4.6.2版本(有具体参数和编译时遇到的问题)

    1.使用的configure配置为:./configure -embedded mips -little-endian -xplatform qws/linux-mips-g++ -prefix /o ...

  7. C++界面库(十几种,很全)

    刚开始用C++做界面的时候,根本不知道怎么用简陋的MFC控件做出比较美观的界面,后来就开始逐渐接触到BCG  Xtreme ToolkitPro v15.0.1,Skin++,等界面库,以及一些网友自 ...

  8. Spring5源码深度分析(二)之理解@Conditional,@Import注解

    代码地址: 1.源码分析二主要分析的内容 1.使用@Condition多条件注册bean对象2.@Import注解快速注入第三方bean对象3.@EnableXXXX 开启原理4.基于ImportBe ...

  9. ABP开发框架前后端开发系列---(7)系统审计日志和登录日志的管理

    我们了解ABP框架内部自动记录审计日志和登录日志的,但是这些信息只是在相关的内部接口里面进行记录,并没有一个管理界面供我们了解,但是其系统数据库记录了这些数据信息,我们可以为它们设计一个查看和导出这些 ...

  10. java.nio.Buffer源码阅读

    Java 自从 JDK1.4 起,对各种 I/O 操作使用了 Buffer 和 Channel 技术.这种更接近于操作系统的的底层操作使得 I/O 操作速度得到大幅度提升,下面引用一段<Java ...