Path: csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!news.glorb.com!postnews.google.com!k3g2000prl.googlegroups.com!not-for-mail From: byhesed Newsgroups: comp.lang.java.programmer Subject: About using assertion Date: Mon, 9 May 2011 07:36:42 -0700 (PDT) Organization: http://groups.google.com Lines: 21 Message-ID: NNTP-Posting-Host: 220.149.108.101 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1304951803 15624 127.0.0.1 (9 May 2011 14:36:43 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 9 May 2011 14:36:43 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k3g2000prl.googlegroups.com; posting-host=220.149.108.101; posting-account=v_GC8QoAAABz34PprEBWdejdnnHZvg4_ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.65 Safari/534.24,gzip(gfe) Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3855 I am reading a book about object-oriented design pattern. The book, Object-Oriented Software Development Using Java 2/e by Xiaoping Jia, says that... =E3=80=80=E3=80=80=E3=80=80=E3=80=80Using assertions derived from the preco= nditions for all methods is known as defensive programming. =E3=80=80=E3=80=80=E3=80=80=E3=80=80Its aim is to prevent a component from = being misused. =E3=80=80=E3=80=80=E3=80=80=E3=80=80Design Guideline: Use Assertions Aggres= sively =E3=80=80=E3=80=80=E3=80=80=E3=80=80Each method should include assertions o= n the preconditions and postconditions of the method and invariants of the class Do I have to always use assertion? Is it better to use assertion? What's your idea?