advertisement
Login | Register   
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   TIP BANK
Browse DevX
Download the code for this article
Partners & Affiliates
advertisement
advertisement
advertisement
advertisement
 

Configuration API Improvements in ASP.NET 2.0

By introducing a spate of new configuration-specific features, .NET 2.0 makes managing your deployed .NET applications a breeze. 


advertisement
icrosoft has greatly enhanced the management tasks for your .NET 2.0 applications by providing a set of configuration APIs that you can use to programmatically access, modify, and save the configuration of an application using minimal code. This article explores the new and enhanced configuration API that ships with .NET Framework 2.0 by providing examples on how to use them from an ASP.NET Web application.

Introducing the ConfigurationManager Class
One important new configuration-related class is the ConfigurationManager class, which provides seamless programmatic access to configuration files and configuration sections. Using the methods and properties of this class, you can open configuration files and retrieve configuration sections from within your application. The ConfigurationMangager class's major functionality falls into three categories.
  • Quick access to the appSettings and connectionStrings sections of the current application's default configuration file, which you access through properties such as AppSettings and ConnectionStrings.
  • Access to a specific configuration section from the current application's default configuration file, using methods such as GetSection, GetWebAppSection, and RefreshSection.
  • The ability to open different types of configuration files such as <AppName>.exe.config, machine.config, and web.config so you can update them programmatically through methods such as OpenMachineConfiguration, OpenMappedMachineConfiguration, OpenExeConfiguration, OpenMappedExeConfiguration, OpenWebConfiguration, and OpenMappedWebConfiguration.
You'll see examples of all of these ConfigurationManager class capabilities. Table 1 shows the most important methods and properties of the class.

Author's Note: For all the examples shown in this article, the ASP.NET process account needs sufficient permissions to be able to read and write into the specified configuration file. For simplicity, to run the samples, enable Integrated Windows authentication through IIS and enable impersonation at the Web site level using the following configuration settings under the <system.web> element in the web.config file.

<identity impersonate="true"/>

Table 1. ConfigurationManager Properties and Methods: The table shows some important properties and methods of the Configuration Manager class.

Property\Method


It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com.
Already a member?



To Software Architects: Serve End Users, Not Your Egos
DevX HomePage

To Software Architects: Serve End Users, Not Your Egos

When the architect job title slipped into the software development lexicon, software engineers became more concerned with building ego-driven monuments than functional skyscrapers.
oftware Architect is a great job title. It looks great on business cards. When someone asks you what you do for a living, you can say you're a Software Architect. It sounds so much better than Software Engineer. The problem arises when this job title leads to the all-too-common behavior of excessive diagrams, rewriting libraries that are available off the shelf, writing wrappers for everything, and instrumentation so excessive that its performance penalties exceed the resource utilization of the actual program's functions. These behaviors are transforming software development from the practical exercise of delivering what the customer needs into the academic endeavor of building gold-plated monuments to our egos.

Without a doubt, building any piece of software more complex than a few hundred lines of code requires careful planning. Larger projects require a division of work among teams, which in turn requires even more planning to ensure that as the pieces come together in the finished product they will work as expected. The person who does this type of planning is the software architect. He or she decides where one chunk of the application ends and the next one begins, determines the contract between that function and the rest of the system, and then hands it off to developers to write the code.

Unfortunately, the majority of software architects don't stop there. Fondly thinking of software development as an academic pursuit, they go on to produce an endless array of diagrams and force fit into them as many design patterns—complete with obscure names like "Tombstone", "Memento", and "Decorator"—as possible. Architects then feel the need to make their own marks on history by inventing a few more patterns, diagramming them, and bestowing them with new names.

The development teams then try to figure out the endless arrays of diagrams and force fit what the architect demands, which leads them to deliver over-budget, yet underperforming systems to the end users. This isn't just conjecture; I've seen it repeatedly at many organizations.

Diagramming is about communicating what you're building, not about conveying your ability to memorize obscure names for common solutions.
At one organization, they had a diagram on one wall that was 14 feet long and 4 feet high with tiny print. The architect was so proud of his masterpiece, his brilliance, his grand work. Minor amounts of investigation revealed that none of the team leads had the slightest clue what this massive diagram really meant, but it sure looked cool and impressed the executives when they visited the development area.

Individual developers had received smaller diagrams, filled with blocks and arrows, that told them exactly how to build their piece of the application. While attempting to interpret the diagrams, they had to resort to Googling the obscure patterns referenced and were made to feel incompetent for not knowing what a "Grafter" pattern was. Diagramming is about communicating what you're building, not about conveying your ability to memorize obscure names for common solutions.

The "Academication" of Software Development
Many in the software industry seem virtually obsessed with trying to make software development as academic as possible. They want to invent new disciplines. The "high priests" of software such as Grady Booch and the Gang of Four (GoF) are all looking to elevate development to a scholarly exercise as opposed to a practical problem-solving endeavor.

Did people make diagrams to describe software before Booch? Sure they did. But since Booch christened diagramming as the Unified Modeling Language (UML), we now have an item to add to our resumes. Did the GoF invent the patterns described in their book? No, software developers have been using them for years. The GoF just gave them names and created yet another meta language for describing what developers do. Meanwhile, countless new programs that could solve all kinds of problems are just waiting to be written and all these scholastic endeavors have produced nothing new in terms of writing innovate code.

Software development is not an academic exercise. It has more in common with the blue-collar "build me a house" ethic than it does with ivory tower research. So let's quit treating it as if it's university research. It's not. Define, design, build, test, deploy—that's what we do.

The "high priests" of software are all looking to elevate development to a scholarly exercise as opposed to a practical endeavor.
Deliver code that does what the end users of the code need or want. No more, no less. From Web sites to database applications to games, it's all about what your code will do for the end user and not about how you did it. Your end users don't care if you used a Booch diagram or anointed blocks with arrows and written descriptions to communicate to the development team how you were going to build the software. They care only that the software works the way they expect it to.

By no means am I suggesting that you shouldn't document your work or plan it out up front. Failing to plan or document is foolish—plain and simple. Turning this planning into an opportunity to show everyone how bright you are is equally foolish and typically much more expensive.

If you're in charge of the software architecture, whether or not you've been bestowed the holy title, keep the focus on designing a system that works. Keep your diagrams simple and understandable. Don't pay too much attention to whether or not it is a proper Booch diagram or whether it utilizes GoF patterns. Don't try to micro-design every developer's piece of the whole, just where it integrates into the whole. Build the system to do what it needs to do, don't gold plate what the users will never see nor care about.

Just build good software on time and within budget.

David Talbot is the Vice President of Development for Data Systems International, a company that develops case-management software for the social services industry. His experience ranges from license-plate recognition using neural networks to television set-top boxes to highly scalable Web applications.
DevX is a division of Internet.com.
© Copyright 2010 Internet.com. All Rights Reserved. Legal Notices
advertisement