2002/05/17

Debug by 蔡學鏞

以下轉載自 Debug本文作者:蔡學鏞張貼日期:05/16/2002

Debug
吃燒餅不免會掉芝麻,寫程式不免會有 bug。再怎麼高明的程式員,也不敢保證寫出來的程式不會有 bug。當發現程式有誤,bug 隱身其中時,就是 debugger 出動的時候了。越是高明的程式員,越是能夠靈巧地使用 debugger,讓 bug 無所遁形。

Debug 的過程分成兩個步驟:
1. 找到 bug 所在地
2. 修正 bug

事實上,真正困難的地方在第一點,如果你能找到 bug 所在地,應該就知道怎麼修正 bug 了。本文章簡單地介紹 debugger 的用法,希望你再次遇到 bug 時,能夠不慌不忙地把這些技巧派上用場。

調整步伐
最不花腦筋的 debug 方式就是:逐行執行,每執行一行程式碼就暫停,立刻觀察這一行的執行結果是否如你所預期,沒問題的話就繼續執行下一行。

當你在逐行執行的時候,如果遇到了 method invocation(函式呼叫),你可以選擇要跳進此 method 或者不跳進此 method。欲跳進此 method,就使用 step in;欲一口氣執行完此 method,就使用 step over。至於要不要跳進去,你可以有自己的考量。一般來說,如果你認定該 method 應該不會有問題時,你就使用 step over,否則使用 step in。

如果已經在某 method 內,但是認為此 method 後面的程式碼不會有 bug,你可以透過 step out 來往上跳,跳離開這個 method。

在 debug 的時候,前進的步伐很重要,step over、step in、step out 三者必須好好搭配使用,才不會「自亂陣腳」。

控制疏密
光靠上面三種 step 方式,要找到 bug,就如同海底撈針一樣,並不容易。你還需要 breakpoint(中斷點)的輔助。

你應該先透過經驗來判斷,bug 最有可能出現在哪些地方。然後在這些地方的前後分別設定 breakpoint。為了加快 debug 的速度,我們經常同時在程式中設定多個中斷點。

在 debug 模式下執行程式時,遇到中斷點,程式就會暫停,我們可以利用這個機會檢視目前的執行結果是否符合預期,如果有差池的話,就表示剛才執行過的程式碼有問題,你已經找到了 bug 的區域,立刻停止此次的 debug 執行模式。接著再重來一次,繼續縮小範圍。當範圍已經很小時,可以改用 step 的方式來找 bug。

分析觀察
不管是導因於 breakpoint 或 step,程式在 debug 模式下暫停時,我們都需要「觀察」(watch)程式目前的狀態(state),據以判斷方才的執行過程有無錯誤。程式狀態其實就是資料的集合,所以我們的「觀察」對象就是程式中的變數值。Debug 工具可以讓我們很方便地觀察程式中各個變數的值,有些 debug 工具還可以讓我們輸入由變數組成的計算式(expression),輸出計算結果以方便我們觀察。

某些 debugger 甚至具有修改變數值的功能,可以讓你在程式暫停時,修改程式狀態,然後繼續執行。

理清頭緒

對於多執行緒(multi-thread)程式,debugger 依然能進行上述的 step、breakpoint、watch。通常 debugger 會在 watch 視窗中以樹狀結構區分出執行緒,然後才個別列出各個執行緒的區域變數,以免混淆。

為了因應撰寫 client/server 程式的需求,有些 debug 工具甚至可以同時幫助多個 process 進行除錯。

隔空抓藥
「捎來藥丸的,可是白鬍子的老公公?」我們姑且相信這個妖婦的確具備隔空抓藥的本事,但提到這樣的本事,許多 debugger 也不遑多讓。越來越多的 debugger 開始支援 remote debugging,讓程式員可以在一部 PC 上,debug 另一部 PC 上的程式。

以 Java 來說,早期 VisualCafe 就提供了自己專屬的 remote agent,來達到 remote debugging 的功能。現在,Sun 的 JVM 都支援 JVMDI(Java VM Debug Interface)以及 JDWP(Java Debug Wire Protocol),所以想設計出一個能隔空抓藥的標準 remote debugger 也不難,主流的 Java 開發工具也開始支援 remote debugging。

de 程式中的 bug,也 de 生活中的 bug

我們除了 de 程式中的 bug,也要 de 生活中的 bug(竊聽器也被稱做 bug)。中國大陸國家主席江澤民的波音 747-300R 座機被裝滿 bug,美鳳姊姊的座車和手機內也被裝了 bug。越是重要的人,周遭的 bug 就會越多,越是需要常常進行 debug。

如果無法確定生活中毫無 bug,請各位務必要做最壞的打算,試圖干擾任何可能存在的 bug,作法很簡單,例如:放大電視機音量、關燈,都很有效。那也就是為什麼,我向親近好友坦承「關燈版」的男主角其實就是我,至今仍然沒有人相信的緣故。

2002/03/12

Book Review: Design Patterns

Design Patterns: Elements of Reusable Object-Oriented Software (Addison-Wesley Professional Computing Series) (Hardcover)
by Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides

Say no more...Gang of four's classic must read.

2002/02/23

Under the Hood of Content Management Systems Part II – The CMS Landscape

Choosing the right Content Management System (CMS) can significantly improve the way an organization manages and shares information internally and externally. This sharing of information, implemented correctly, can lead to critical improvements in sales, support, partnering, hiring, marketing, and investor relations.


The number of Content Management applications available on the market today is staggering. All of the major software vendors have their own version of a CMS as do many midsize software companies. This breadth of available CMS software offers a wide range in functionality, complexity, and price. There is now a CMS solution for every business need. Finding the ideal CMS solution that fits the specific needs of the organization’s content strategy is critical.


Before any Content Management System is demonstrated or chosen, the organization should first examine all of the business requirements for such a system. Long term goals should be defined for the CMS and factors such as IT resources, training needs, integration needs, hardware, content writers, and web developers should be considered. By not fully taking into consideration the business needs, organizations may select the wrong CMS and then be forced to spend large amounts of money to customize it to fit business requirements. It is better to fully research the intended uses of the system and purchase a CMS that already fits specific business requirements. Costs in licensing, installation, configuration, and maintenance are major factors in determining which CMS solution is right for your objectives. In the long run the CMS should be modeled around your organization’s business process rather than the other way around. A well thought out CMS strategy will also help in getting buy-in from executive management and employees.


The following is a general list of CMS solutions on the market today. These systems, which range in price from free to approximately $500,000 in licensing fees represent a representative sample of the types of CMS solutions available.


Please note: the categories and systems below are not exclusive of each other. Many products span multiple categories.



Enterprise Content Management Systems


For mid- to large-size organizations with dozens to hundreds of staff writing and managing content, an Enterprise Content Management System (ECMS) will automate tasks involved in managing large scale content deployments. These systems are powerful applications with custom workflow controls, powerful templating modules, object caching, clustering, and documented methods for integration with organizational applications. Most Enterprise Content Management Systems will also have modules for detailed reporting, user groups with specific roles/permissions, and versioning.


Lotus Workplace Web Content Management


This system, previously called Aptrix, provides a tight integration with both WebSphere and Lotus / Domino systems. LWWCM has one of the most intuitive interfaces on the market allowing for easy training and maintenance. Customizable tabbed forms enable users of most technical backgrounds to easily create and manage content across the site. This system dynamically renders static content for the live site. As a fairly new system to IBM, this CMS is currently lacking good documentation and training programs.


http://lotus.com/products/product5.nsf/wdocs/homepage



Microsoft Content Management Server


The largest software provider in the world has come out with many powerful server applications for its business customers within the last several years. The Microsoft Content Management Sever is a powerful CMS, based on NCompass purchased in 2001, for organizations that utilize the Microsoft Platform. This system provides one of the best application frameworks on the market with well documented APIs, open code, clear database integration, and industry standards in interoperability and formatting. Editing tools for the CMS integrate with Internet Explorer allowing users to edit the website from within the browser. In their typical fashion, Microsoft is coming from behind in this industry making significant improvements in this system with every iteration.


http://www.microsoft.com/cmserver/



Global Content Management Systems


Multiple web sites with content in various languages targeted at a variety of audiences around the globe can be difficult to manage. Powerful CMS solutions with strong templating components, Unicode compliance, distributed architectures, complex workflow, and multifunctional formatting tools allow managers within organizations to manage web sites that provide information to users around the globe with localized designs and content. Significant improvements have been made in this category of content management over the past two years as more and more companies strive to enable global companies to cater to worldwide customers and employee bases. These systems are designed specifically for large multinational organizations with thousands of employees, hundreds of thousands of documents, and websites with thousands of pages.



Interwoven TeamSite


For many organizations, TeamSite is the Content Management standard. With the latest release, TeamSite 6.0, Interwoven has enabled users to customize the interfaces of its powerful Content Management Solutions. With tools for versioning, user security, web content editing, document sharing, media administration, and publishing – TeamSite has become one of the most recognized names in web site management. Extractable is an Interwoven partner.


http://www.interwoven.com



Stellent


Stellent’s Content Management System is an end-to-end solution that delivers content quickly. Flexible tools for templating and workflow make it possible to maintain growing volumes of content from a wide variety of sources and make that content accessible across an entire enterprise. Stellent’s powerful versioning functions are also ideal for application deployments. One of the powerful functions that makes Stellent stand out in the CMS world is its integration with the underlying folder structure on the server. User can save documents from editors (MS Word) to a directory on the server and the CMS will automatically categorize, format, and upload the document to the system.


http://www.stellent.com



Application Content Management Systems


If a site requires dynamic functionality such as ecommerce, CRM, personalization, security features, and/or integrated applications, a Content Management System specializing in application management and integration is required. There are many Application Content Management Systems that easily integrate content tools with enterprise and e-business applications for a seamless solution. As the web becomes more and more functional, sites are requiring robust functional components with dynamic data and more and more Content Management Systems are starting to have application management components.



Vignette


Vignette V7 is an integrated platform of applications and web services to create and manage information, business processes, portals and applications. The Vignette Command Center is a configurable, role-based management console that enables business and technical users to manage virtually all of their electronic assets and delivery applications through one interface. What Vignette makes up for in developing dynamic sites, it lacks in versioning. Vignette users often need to write or integrate their own versioning system.


http://www.vignette.com



WebSphere Portal


IBM’s WebSphere is more of an Application Server than a Content Management System. But this powerful set of applications has several impressive Content Management features. With WebSphere organizations can create secure customer portals with dynamic content that are easily managed by users throughout an organization.


http://www-306.ibm.com/software/info1/websphere/index.jsp?tab=products/portal



Document Content Management


Large organizations that share content with partners, internal staff, distributors, and/or customers have content in many different formats. A powerful Document Content Management System allows enterprises to share information in virtually any format over the web, across the network, via email, and/or through powerful versioning systems. Collaboration tools integrated directly with the document creation process allow multiple people within an organization to contribute content to the same document in well-defined and easy to use workflow processes. Powerful collaboration tools enable users to not only create content but associate all available meta information with processes and content components.



Documentum


Document, now a division of EMC, has for a long time been one of the biggest players in document management. Their powerful tools allow large organizations to automate many of the functions involved in collaborative information creation and management. Tightly integrated tools allow users to create documents, or components of a document (ie. an Executive Summary), in most popular formats and selectively/securely share this information across or outside the organization. With a large focus on customer support, Document excels in offering training, documentation, and consulting services.


http://www.documentum.com



FileNet


One the first players in the content management market, FileNet is deeply ingrained in a lot of large organization information sharing structures (80 of the Fortune 100). FileNet tools are built around the needs of large diverse organizations and great for implementing standards in content structures, workflows, and storage.


http://www.filenet.com



Specialty Content Management


Some CMS solutions are built with specific content in mind. Unique pieces of content such as Property Leases, Digital Movies/Music, and Electronic Design Automation content have distinct rules, workflows, and management requirements. For organizations with content that requires management components different from traditional CMS solutions, specialty systems may be the answer.



InterWoven MediaBin


MediaBin is a Digital Asset Management (DAM) solution used by marketing organizations to manage large amounts of digital assets (Images, Movies, Music, Collateral Templates, etc) and marketing content used to promote products and brands. With MediaBin, extended marketing teams easily catalog, manage, transform, and distribute digital assets, including photographs and logos, audio and video, datasheets and ads, presentations and documents.


http://www.interwoven.com/products/dam/



SumTotal Learning Content Management system (LCMS)


Formed from the merger of Click2Learn and Docent, the SumTotal Enterprise Suite helps organizations manage the content used to educate audiences such as employees, partners, and customers. This robust system provides friendly tools for managing learning content such as movies, manuals, and presentations. This system not only focuses on sharing information, but also improving productivity.


http://www.sumtotalsystems.com/



Custom Content Management Systems


All Content Management Systems require developers to perform configuration and integration before they can be used by an organization. In many cases unique requirements or budgetary constraints make out of the box Content Management Solutions inappropriate for achieving the organization’s business goals. Custom CMS solutions enable organizations to satisfy specific critical requirements and maintain a high level of future flexibility. There are development tools such as Rich Text Editors (WYSIWYG), workflow components, and versioning libraries that make custom CMS development the right solution for many organizations. OpenSource CMS solutions, such as OpenCMS and the Apache Cocoon Project allow developers to customize pre-built CMS functions to fit specific needs. Examples of Custom CMS solutions and components include:



Entry Level Content Management Systems


Smaller organizations with simple objectives require low priced CMS solutions that fit the basic requirements for managing websites without related IT costs. Systems in this category require a high level of easy-to-use interfaces that do not necessitate classes and technical support for implementation. Most CMS solutions in this category will lack complex workflows, detailed reporting, clustering, and/or personalization. Instead these systems will focus on the core functions such as editing and publishing. Entry level systems have come along way in the past two years and are a great fit for a wide variety of organizational needs.



Macromedia DreamWeaver/Contribute


This excellent package provides friendly editors with simplified tools for deploying data to public websites. DreamWeaver has a well-deserved reputation for being one of the best WYSIWYG (What You See Is What You Get) editors on the market. Advanced configurations allow developers to create security around template components to ensure specific users and editing only the content that pertains to them. Contribute brings workflow and publishing components to the DreamWeaver editor to enable users with varying levels of technical backgrounds to manage web content.


http://www.macromedia.com/software/contribute/?promoid=home_prod_contribute_082403



Ektron


Ektron was one of the first companies to bring Rich Text Editing to the web and has since created several components to perform common content management functions. Ektron has such a demonstrated lead in the WYSIWYG market that many of the higher end CMS tools mentioned above have integration options for Ektron components. The company's entry-level software costs below $500 for five users, but this version comes without publication user/group permissioning and deployment scheduling.


http://www.ektron.com/cms300.aspx



If you have any questions about CMS options or need assistance in researching your company’s CMS requirements, please contact us at mtsai@extractable.com.


- Ming Tsai




Additional Resources - CMS Vendors



  • Atomz

  • BroadVision

  • Documentum

  • Ektron

  • FatWire

  • FileNet

  • IBM WebSphere

  • Ingeniux

  • Interwoven

  • Lotus Workplace Web Content Management

  • Macromedia

  • Microsoft

  • Midgard

  • Objectify

  • OpenCMS

  • Oracle

  • PaperThin

  • Percussion

  • Red Bridge Interactive

  • SimplyCMS

  • SiteWorks Pro

  • Stellent

  • SumTotal Systems

  • Vignette

  • WebWord

  • Zope

Other useful sites:



  1. http://www.Cms-forum.org

  2. http://www.cmswatch.com

 

2002/02/13

Under the Hood of Content Management Systems - Part I – What is a CMS?

Content Management Systems - these three words can create feelings of elation or frustration in internet professionals depending on their past experiences. Loosely defined, content management systems (CMS for short) are applications designed to make content publishing online easier and/or more structured. In the past several years, the term has been applied to a wide variety of software and database packages offering a wide spectrum of services and functionality.


Our two-part series of articles is designed to shed some light on CMS - its purposes, functions, broad categories, and current market players. This article begins with the basics, describing the functional components of content management systems. Part one is intended as a primer for people who want to understand how content management systems can help their business.


In part two, we will cover the broad categories of CMS. We will discuss the differences between enterprise platforms and their smaller competitors. We will also look at low-priced and open-source options. Finally, we will discuss some specific software packages that stand apart in a crowded marketplace.


What is Content Management?


As any web manager can attest, keeping web site content fresh is a tricky business. In many organizations, the individuals that seek to add new content are different than those that create content, who in turn are different than those that put it on the web site. The back-and-forth between owners, contributors, approvers, producers, and web owners can mean real delays in posting timely content, frustration that small changes take forever, and a significant investment of man-hours when multiple people are involved. Compound this with the integration of third parties, such as an interactive agency responsible for content production, and the end result may be a web site that stagnates with a lack of fresh content.


Content management systems are designed to increase efficiency in content publishing. Some systems are very tactical, making it easier for non-technical users to publish directly to the site (thereby obviating the role of "producer"). Others offer more comprehensive content workflow, making it easier for approvers and owners to be involved. The largest systems provide a comprehensive framework that integrates across the enterprise to deliver content to multiple sources, including a web site.


The Functions


In order to understand what content management systems do, we will describe their functionality starting with the most basic components. We will build on these to demonstrate how more and more robust systems supplement CMS functionality with complex management processes.


Content publishing - The heart of any CM system is the ability to publish content to a web site or intranet. At its most basic level, this provides users with the tools necessary to input content, view it for quality assurance, and push it live to the site. Typically, this means that a specific type of content is put in a specific place on the site in a specific format. A good example of this is a press release.


Press releases must be posted very rapidly depending on their nature. The originators of press release content (say, the investor relations group) may not be affiliated with the web group and may not be technically savvy. A simple form-based content publishing tool allows the content originator to use an online form (typically intranet-based with password protection) to input specific content into pre-defined areas. For a press release, these areas might include "title", "byline", and "body content". When users fill out the form and click the submit button, they are presented with a preview of the page. The content is automatically placed in specific areas of the page, formatted with the appropriate fonts, "wrapped" in the correct site design, and located in the correct part of the site architecture. By clicking "approve", the content is pushed live and the process is complete.


Even simple content publishing tools can have relatively complex technology on the back-end. The system must incorporate functionality to effectively link the site from the site navigation or an index page. In the above example, the "title" field will be used as a link from the press releases page of the site and incorporated dynamically. Many content publishing tools use databases to manage the content. Others will dynamically create "flat files", essentially simple text documents, which are read by the site.


A key limitation of this type of system is that it applies to specific types of pages that need to be updated frequently, such as press releases, events, and announcement sections of a site, rather than publishing to any page on a site. Full-site publishing (below) addresses this need.


WYSIWYG editing


Many types of software packages exist allowing WYSIWYG (What You See Is What You Get) web page development. Built as fully functional software applications, these tools allow users to build web pages without any real knowledge of HTML. Pages are built using a Microsoft Word- or PowerPoint-style editor, allowing users to format content and imagery on the page.


Some content management systems offer formatting controls allowing users to modify how content looks on the page. This can be as simple as allowing font choices, color choices, bold/italic/underline, etc. It can be as complex as full WYSIWYG editing allowing robust control for image placement, tables, and forms. Some WYSIWYG suites have incorporated many of the other functional components we describe in this article, turning them into functional CMS applications.


Full-site publishing


More robust systems take this concept of content publishing and extend it to all pages of the site. Essentially, the methodology for this type of system is similar to content publishing (above) with the addition of tools to allow users to access multiple pages across the site. Users typically access a directory tree to find the site area or specific page to modify. All of the modifiable pages are template-based, meaning that they share design templates that dictate content location, image location, etc. Multiple templates can be used for different areas of the site.


Integration of site


Wide CMS tools is serious business. This is best done as the site is being built out for the first time - retrofitting a site to integrate CMS can often mean rethinking how content, imagery, and navigation are used.


Workflow


Once a system is put in place allowing users to add content to a site, a key corporate requirement quickly presents itself: oversight. Workflow processes provide the communication framework allowing system-based approval processes that are critical for effective site management. In many corporations, approval requirements are varied. Even in a simple corporate structure, once a contributor creates new content, it may need to be approved by the content owner, legal, and site administrator. If any one of these approvers asks for revisions, the process must repeat itself. Workflow systems help to make this process efficient and easy. When a contributor submits content, an email is automatically sent to a predetermined approver or group of approvers. The approver reviews the content in the system and can either approve or reject it. If rejected, it is automatically sent back to the contributor with comments. If approved, it moves to the next person in the approval chain, and so on.


Because these systems are email-based, reviews and approvals can be completed very quickly, reducing the time that manual approvals can take. These systems also provide a documentation trail that many corporations now require for corporate accountability.


Version control


Version control provides a fail-safe mechanism for rolling back versions of content. If content is pushed live that is incorrect, site administrators can use version control systems to immediately go back to a previous version. These systems will often archive content indefinitely, allowing a content trail that can be used for corporate accountability. The biggest benefit of version control is speed. Fixing an error on a page can be as easy as pushing a button.


User Management


In a complex site development environment, system users must have a variety of permissions. These are typically assigned both vertically and horizontally. Vertical permissions define the role that users have as they access the system. A simple role hierarchy might be:


¨ Author - An Author is permitted to create and modify content. All content modifications by an Author must be approved.


¨ Editor - An Editor has same permissions as an Author. In addition, an Editor is permitted to approve/deny content modifications from Authors. Editors may be able to promote content to the live environment.


¨ Administrator - An Administrator has all of the permissions as the above two roles. In addition, Administrators may create/delete/modify users as well as modify template-based content such as navigation.


Horizontal permissions typically permit users to access different sections of the site. Corporate Communications users, for example, may only be permitted to modify content within the Investor Relations and About Us sections of a site. Corporate Communications users will be a mix of Authors and Editors. Administrators typically have all-site access.


User management not only defines the permissions that users have, but usually provides the security infrastructure governing site access. This includes password protection and integration with corporate access protocols.


Multiple Combinations


The CMS components described above represent the range of functionality that different systems offer. How individual CMS packages differ is dependant on how these components are combined as well as the scale at which they are offered. Some packages offer all of these functions, but are only capable of working with small sites. Others offer one or two functions targeted at large enterprises.


In our next edition of Extracts, we will discuss the various categories of CMS platforms as well as highlighting some of the most well-known software packages. If you have any immediate questions about content management, please feel free to contact me at mtsai@extractable.com.


2002/02/03

Book Review: The Object Primer

MUST HAVE!

The Object Primer
by Scott W. Ambler

Even though object-oriented programming (OOP) has been around for many years and is taught in the computer science programs at colleges and universities, there are still many developers who do not know it. What this means is that those who are now performing the migration to OOP are primarily old dogs that need to learn the latest tricks. This book is perfect for that task, Ambler writes very clearly and covers all of the major aspects of OOP.
There are two outstanding features of the book. The first is the clear writing style and the second is the completeness of coverage. Not only are the fundamentals of OOP covered, but the Unified Modeling Language (UML) is also introduced. Since the U in UML could now be considered a representative for Universal, most developers need to be able to understand it. Ambler also covers some of the basic features of design patterns, components, use cases, object-oriented analysis, object-oriented design and object-oriented testing. These are generally considered to be advanced topics, but as presented here are well within the level of an introductory book.
The only negative point is the significant amount of duplication that is done. For example, on page 410 there is a boxed region for the definition:

Subject Matter Expert (SME) - A person who is responsible for providing pertinent information about the problem and/or technical domain either from personal knowledge or from research.

An excellent definition, but the problem is that it was already defined on page 35 and was used many times in the pages between 35 and 410, especially in the chapter on gathering requirements. There are many similar situations throughout the book, so many that I often considered segments redundant.

This book could also be used as a textbook in a course on the principles of object-oriented programming without using a specific language. Some Java code is used, but it is very skeletal and is used to demonstrate the initial steps in constructing your application from the design principles.

2002/01/17

Book Review: Effective Java Programming Language Guide

Effective Java Programming Language Guide
by Joshua Bloch

I got this book after programming Java for about 3 years....I can tell you that I've already learned more about Java by reading this book than any other book (or actual programming).

This book will make you think about your code in new ways. There are concepts in this book that make you think, why didn't anyone tell me that (or explain it to me that way)?

THIS IS ANOTHER BLACK BOOK YOU MUST HAVE!

Mercury簡易改裝

有同好有一樣的困擾 - 如何使用自己的data logging軟體,因此寫了這篇來分享我的簡易改裝。 Background 雲豆子 MERCURY roaster 烘豆機的設計是使用自行開發的軟體,來:1. 操控風門/火力; 2. data logging/自動烘焙。 ...