Agile Methodology – An Overview
Gartner defines Agility as "the ability of an organization to sense environmental change and respond efficiently and effectively to that change." Sensing the need for change also includes the proactive initiation of change.
Rapidity of business change is driving a need for agility to respond more effectively to change.Organizations needed to make development process changes should strongly consider using Agile rapid applications development methodologies as part of moving to service-oriented development of applications.
Any enterprise that aspires to respond in real time must have the ability to be agile when needed. Agile is successful because it:
Stresses customer satisfaction
Emphasizes team work (simple, yet effective way to enable groupware style development)
Allows agile programmers communicate with their customers and fellow programmers quite regularly and empowers them to confidently respond to changing customer requirements, even late in the life cycle
Why Agile
Traditionally, software development has been process-centric.
Agile methodologies change the face of software development by giving it a human touch (people over processes).
Customers value ROI and time-to-market.
Agile methodologies help in increasing ROI as well as reduce time-to-market. (incremental working software)
Customers see quality, productivity and turn-around time as a risk when it comes to off-shore software development.
Agile methodologies build trust and confidence as the customer is part of the team and the techniques used reduce the offshore risks. (customer collaboration and embracing change)
Development Firm
Critical Success Factors
Use Continuous Integration to Avoid Integration Headaches
Have Each Site Send Ambassadors to the Other Sites
Use Contact Visits to build trust
Don't Underestimate the Culture Change
Use wikis to contain common information
Use Test Scripts to Help Understand the Requirements
Use Regular Builds to Get Feedback on Functionality
Use Regular Short Status Meetings
Use Short Iterations
Use an Iteration Planning Meeting that's Tailored for Remote Sites
When Moving a Code Base, Bug Fixing Makes a Good Start
Separate teams by functionality not activity
Expect to need more documents.
Get multiple communication modes working early.
Client : A leading supplier of media and technology solutions to connect Health care professionals to customers
Salient Features
The Core / Remote Team Model
Phased Requirements
Project Transitioning
Multiple Technical Approach
Agile Source Control
Agile Testing
Daily & Weekly Meetings
Change Request Management
Agile Requirements & Implementation
1. Planning requires user/programmer cooperation in defining feature benefits and costs. - The Core Team Model, The Remote Team Model.
2. Small releases put out a simple system early and update it often. - Phased Requirements.
3. Simple design value comes from the simplest program that meets requirements. - Multiple Technical approch.
4. Re-factoring has Agile teams correct system design defects and recode as necessary - Multiple approch & Agile source control.
5. Testing has programmers write tests first, and then create software to fulfill test requirements. - Agile Testing
6. On-site customers set priorities, answer programmers' questions and cut documentation costs. - Daily & weekly status meeting.
7. Pair programming has programmers write all production code in pairs, sharing a single machine. - Agile source control
8. Collective ownership implies shared responsibility for code function and quality. - Daily & Weekly Meetings,
Project Transitions, Change Request
Management, The Core Team Model, The Remote Team Model.
ஏஞ்சல்
என்னை பற்றி
Google reader
Categories
- .Net (9)
- .Net Crystal Report (1)
- .Net GridView (3)
- Articles (5)
- Log File .Net (1)
- Sharepoint (2)
- Sitefinity 3.7 (3)
- SQL (5)
- Technical Question and Ans (3)
- Validation (1)
- XML (2)
Wednesday, May 19, 2010
Agile Methodology
Sunday, February 28, 2010
Design Patterns
Design patterns are recurring solutions to software design problems you find again and again in real-world application development. Patterns are about design
and interaction of objects, as well as providing a communication platform.
Design patterns
Creational pattern
Abstract Factory --->Creates an instance of several families of classes
(Provide an interface for creating families of related or dependent objects without specifying their concrete classes.)
Builder --->Separates object construction from its representation
(Separate the construction of a complex object from its representation so that the same construction process can create different representations..)
/>
Factory Method--->Creates an instance of several derived classes
(Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses)
Prototype--->A fully initialized instance to be copied or cloned.
(Specify the kind of objects to create using a prototypical instance, and create new objects by copying this prototype.)
/>
Singleton--->A class of which only a single instance can exist.
(Ensure a class has only one instance and provide a global point of access to it.)
/>
Structural pattern
Adapter--->Match interfaces of different classes
(Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible
interfaces.)
Bridge--->Separates an object’s interface from its implementation
(Decouple an abstraction from its implementation so that the two can vary independently.)
Composite--->A tree structure of simple and composite objects
(Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.
)
/>
Decorator--->Add responsibilities to objects dynamically
(Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.)
/>
Facade--->A single class that represents an entire subsystem
(Provide a unified interface to a set of interfaces in a subsystem. Façade defines a higher-level interface that makes the subsystem easier to use.)
Flyweight---> A fine-grained instance used for efficient sharing
(Use sharing to support large numbers of fine-grained objects efficiently.)
/>
Proxy--->An object representing another object
(Provide a surrogate or placeholder for another object to control access to it.)
/>
Behavioral pattern
Chain of Resp--->A way of passing a request between a chain of objects
(Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the
request along the chain until an object handles it.)
/>
Command--->Encapsulate a command request as an object
(Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations. )
/>
Interpreter--->A way to include language elements in a program
(Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.)
/>
Iterator --->Sequentially access the elements of a collection
(Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.)
Mediator--->Defines simplified communication between classes
(Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly,
and it lets you vary their interaction independently.)
Memento--->Capture and restore an object's internal state
(Without violating encapsulation, capture and externalize an object's internal state so that the object can be restored to this state later.)
Observer--->A way of notifying change to a number of classes
(Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.)
State--->Alter an object's behavior when its state changes
(Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.)
Strategy---> Encapsulates an algorithm inside a class
(Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.)
Template Method--->Defer the exact steps of an algorithm to a subclasse.
(Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an
algorithm without changing the algorithm's structure.)
Visitor--->Defines a new operation to a class without change
(Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the
elements on which it operates.)
Wednesday, January 20, 2010
MVC & 3 Tire Architecture
Model View Controller (MVC)
Introduction:
Design patterns are very useful to solve complex design problems if used properly. This article explains the basic concept of the Model View Controller (MVC) Design pattern and also shows how closely.
Prerequisites
Object Oriented-programming concepts, .NET Framework, ADO.NET, C#, XSD.
Definition/Description: Model View Controller (MVC)
View renders the data from the Model in response to the request made to the model by controlled events made by user interaction.
Model View Controller is a design approach to separate the application object model from GUI, originally invented around 80s. Then later on it has become a widely accepted common design pattern. The main objective behind this pattern is to decouple the view of the data (presentation layer) from the actual data processing so that the same model can be used for various views. This is achieved by using three different types of objects that interact with each other in loosely coupled manner with their discreet set of tasks.
These three objects are known as Model, View and Controller. We will learn for each of them here.
VIEW:
View is the graphical data presentation (outputting) irrespective of the real data processing. View is the responsible for look and feel, some custom formatting, sorting etc. View is completely isolated from actual complex data operations. For example, Online product catalog view is completely separated from database connection, query, tables etc. It simply gets final row-data from the model and puts some cosmetics and formatting before displaying it in browser. View provides interface to interact with the system. The beauty of MVC approach is that it supports any kind of view, which is challenging in todays distributed and multi-platform environment.
A MVC model can have multiple views, which are controlled by controller. View interface can be of WEB-FORMS, HTML, XML/XSLT, XTML, and WML or can be Windows forms etc.
MODEL:
Model is responsible for actual data processing, like database connection, querying database, implementing business rules etc. It feeds data to the view without worrying about the actual formatting and look and feel. Data provided by Model is display-neutral so it can be interfaced with as many views without code redundancy; this eases your code maintenance and reduces bugs and allows code -reuse at good extent. Model responds to the request made by controllers and notifies the registered views to update their display with new data.
CONTROLLER:
Controller is responsible for Notice of action. Controller responds to the mouse or keyboard input to command model and view to change. Controllers are associated with views. User interaction triggers the events to change the model, which in turn calls some methods of model to update its state to notify other registered views to refresh their display.
Benefits:
Following are the few of the benefits of MVC design pattern.
Since MVC handles the multiple views using the same enterprise model it is easier to maintain, test and upgrade the multiple system.
It will be easier to add new clients just by adding their views and controllers.
Since the Model is completely decoupled from view it allows lot of flexibilities to design and implement the model considering reusability and modularity. This model also can be extended for further distributed application.
It is possible to have development process in parallel for model, view and controller.
This makes the application extensible and scalable.
Drawbacks:
Requires high skilled experienced professionals who can identify the requirements in depth at the front before actual design.
It requires the significant amount of time to analyze and design.
This design approach is not suitable for smaller applications. It Overkills the small applications.
.NET and MVC:
Lets try to find out how closely ASP.NET allows architecting application to meet MVC concept.
Model: Dataset/Business Entities, DataAccess components
View: .ASPX pages
Controller: Code-behind .vb/.cs files
Typed dataset is one of the greatest features in .NET, which holds the application data in memory and represents the application business entity model, which bridges the UI components with Service Interface and Data Access layer.
So, service interface and Data Access components populate these typed Datasets. Now, these filled datasets can be bound to any view in UI layer.
.ASPX and ASCX pages server as view and mean to interface with application, while the code behind classes for these files server as the controller functions.
ASP.NET doesnt have central controller function, instead the code-behind file can directly make request to the Model and can update the dataset. But lot of controller function can be implemented in code behind class events in .aspx or .ascx pages, like Page_Onload(), OnItem_Created() etcevents.
.NET Framework has all Object-oriented features like code reuse, encapsulation etcSo, proper design of your model can make your user interface and view completely separated from model which can server multiple views.
Reference
Sunday, December 13, 2009
3. Architecture
.Net 3.0 runtime
Contains the core pillars (WPF, WWF etc) and runtime components. If we wish only to run any .net 3.0 application, installing .net 3.0 runtime is enough.
While the .NET Framework 2.0 class library is partially superseded by the new components (WF, WCF, and WPF) added in version 3.0, many portions of the original class library are still crucial to developers. The technologies of version 2.0 (ASP.NET, WinForms, ADO.NET, XML etc.) largely remain the elementary part of the new release; however, .NET framework 3.0 developers may now prefer using WPF over Windows Forms for writing a native Windows GUI.
Windows Workflow Foundation (WF)
WF broadly comprises of the following assorted components:
Activity: A unit of work ranging from very simple to quite complex.
Workflow: A group of activities that partially or completely implements a business process.
WF Designers: The graphical tools to create and modify workflows and activities.
WF Base Activity Library: A fundamental group of activities (IfElse, While, Listen etc. design constructs) used to create workflows. These are quite similar to the BizTalk Orchestration shapes.
WF Runtime Engine: A library that executes workflows. It also provides other services, such as communicating with software outside the workflow.
Host process: A Windows application that hosts the Windows Workflow Foundation runtime engine, workflows, and runtime services for persisting a workflow's state, handling transactions, etc.
WF provides the Workflow Designer, a Visual Studio-hosted graphical tool for creating workflows. The activities in a workflow can be drawn using the Base Activity Library (BAL) provided with WF.
Windows Communication Foundation (WCF)
However applications are built (using workflow or otherwise), most of them need to communicate with each other. This inter-application communication has taken a big leap forward in the last few years. After a perpetual era of disagreement, all of the major vendors agreed to support SOAP based Web services which makes interoperability between applications built on different technology platforms, such as J2EE and the .NET Framework, significantly simpler. So, this also makes the idea of service-oriented architecture much more plausible for most organizations.
A lot of communication approaches exist in the .NET Framework 2.0 such as ASP.NET Web Services, .NET Remoting, System.Messaging supporting queued messaging through MSMQ, Web Services Enhancements (WSE) - an extension to ASP.NET Web Services that supports WS-Security etc. However, instead of requiring developers to use a different technology with a different application programming interface for each kind of communication, WCF provides a common approach and API. "WCF is actually an old wine in new bottle", and was previously called as Indigo. In the .NET Framework 3.0 environment, most applications that might have used one of the communication technologies listed above will instead use WCF.
WCF provides strong support for interoperable communication through SOAP. This includes support for several specifications, including WS-Security, WS-ReliableMessaging, and WS-AtomicTransaction. WCF doesn't itself require SOAP, so other approaches can also be used, including optimized binary protocol and queued messaging using MSMQ. WCF also takes an explicit service-oriented approach to communication, and loosens some of the tight couplings that can exist in distributed object systems, making interaction less error-prone and easier to change. Thus, WCF addresses a range of communication problems for applications. Three of its most important aspects that clearly stand out are:
Unification of Microsoft�s communication technologies.
Support for cross-vendor interoperability, including reliability, security, and transactions.
Rich support for service orientation development.
To sum up, communication between applications, whether within an organization or across, is a fundamental part of any modern software. The .NET Framework 3.0 attempts to address enduring communication challenges by using the service-oriented approach of WCF.
Windows CardSpace (WCS) Digital identities are the way how people electronically represent themselves today on the Internet. In the majority of cases, a person's digital identity is expressed as a simple username, and when its combined with a password, it is used to access web sites, email servers, e-merchants, online banks etc. Yet, despite their simplicity and popularity, usernames and passwords haunt people. Many of us have a hard time remembering all of the usernames and passwords of different sites. Thus, some people use the same values for different sites, easing the memory problem but increasing the security risk.
Usernames, passwords, and other personal information can be stolen by phishers. By sending delusory emails, phishers entice their victims to log in to their Web site that looks just like, say, the site of the victim's bank. So once the victim enters his username and password, the phisher can use this information to masquerade as the user on the real site.
Reducing occurrences and severity of these problems requires an entirely new approach to managing digital identities. WCS (originally called InfoCard) provides this. It helps people keep track of their digital identities as distinct information cards. If a Web site accepts WCS logins, users attempting to log in to that site will see a WCS selection. By choosing a card, users also choose a digital identity that will be used to access this site. Rather than remembering a plethora of usernames and passwords, users need only recognize the card they wish to use.
The identities represented by these cards are created by one or more identity providers. These identities will typically use stronger cryptographic mechanisms to allow users to prove their identity. WCS itself also includes a self-issued identity provider that runs on client machines. With this provider, users can create their own identities that don't rely on passwords for authentication.
So if passwords aren't used to log in to a site, phishers can inflict no harm either. Well, not really! Phishers, if somehow, can trick a user to log into a bogus site, might be still able to acquire personal information of the user, such as sensitive medical information etc. Preventing this requires that users be able to distinguish real sites from the look-alike fakes created by phishers. To allow this, the organization that owns a Web site can get a high-assurance certificate. Unlike today's simple SSL certificates, acquiring this new kind of certificate involves a much more rigorous process, including stronger proof that the organization applying for it actually is who it claims to be. A high-assurance certificate can also carry a company's logo and other information to help the user correctly determine whether a site using this certificate is legitimate. When a user accesses a new site, WCS always displays the information in that site's certificate using a standard screen. Based on the strength of the certificate received, this screen will indicate different levels of assurance of the site's identity.
Windows Presentation Foundation (WPF)
User interfaces are an important part of most Windows applications. No matter how much software evolves, traditional menu-driven GUIs are here to stay for some more time. Similarly, the need to display video, run animations, use 2/3D graphics, and work with different document formats also cannot be superseded. And all of this must be possible whether the application is a stand-alone desktop client or is accessed through a Web browser.
So far, all of these aspects of the user interface have been provided in different ways on Windows. For example, a developer needs to use Windows Forms to build a Windows GUI, or HTML/ASPX/Applets/JavaScript etc. to build a web interface, Windows Media Player or software such as Adobe's Flash Player for displaying video etc. The challenge for developers is certainly clear: building a coherent user interface for different kinds of clients using diverse technologies isn't a simple job.
A primary goal of WPF (originally called Avalon) is to address this challenge! By offering a consistent platform for these entire user interface aspects, WPF makes life simpler for developers. By taking a more modern approach, including support for video, animation, 2/3D graphics, and various kinds of documents, WPF can let users work with information in new ways. And by providing a common foundation for desktop clients and browser clients, WPF makes it easier to build applications that address both.
Another challenge that has long faced the creators of user interfaces stems from the different roles required for building effective interfaces. Software developers are needed to create the logic behind the interface, and Designers are required to define the interface's look and feel. Yet older technologies such as Windows Forms are focused entirely on the developer. There's no truly effective way for developers and designers to collaborate. To address this issue, WPF relies on the eXtensible Application Markup Language (XAML). An XML-based language, XAML allows specifying a user interface declaratively rather than in code. This makes it much easier for user interface design tools like MS Expression Blend (originally branded as MS Expression Interactive Designer and code named as Sparkle) to generate and work with an interface specification based on the visual representation created by a designer. Designers will be able to use such tools to create the look of an interface and then have a XAML definition of that interface generated for them. The developer imports this definition into Visual Studio, then creates the logic the interface requires.
Developers can also build a XAML browser application (XBAP) to create a remote client that runs inside a Web browser. Built on the same foundation as a stand-alone WPF application, an XBAP allows presenting the same style of user interface within a downloadable browser application. The best part is that the same code can potentially be used for both kinds of applications, which means that developers no longer need different skill sets for desktop and browser clients. The downloaded XBAP from the Internet runs in a secure sandbox (like Java applets), and thus it limits what the downloaded application can do.
Burp, GUI is a complex but an important part of the modern applications. Through WPF, the .NET Framework 3.0 presents a more complete and consistent solution to the challenges these interfaces present. The goal is to let people who create user interfaces (both developers and designers) effectively collaborate and do their jobs more expeditiously. So beware, because when your boss hears all this, she/he will certainly start expecting more from you.. : ( But I guess, that is the flip side of adopting any new technology.
Cocktails
�As an ideal meal cannot conclude without cocktails, so cannot a technology review without addressing criticism�.
Of late, I have came across some criticism of .NET 3.0 release and its branding on grounds that the new release doesn't accommodate .Net 2.0 bugs or language enhancements (like LINQ). It is also said that it does not add up anything substantial (other than WinFx lib) and that there shall be no performance gains too. Some even envisage the .Net 3.0 release as an improvised marketing ploy to hype up the forthcoming Vista release.
On the contrary, the re-branding from WinFx to .NET Framework and regrouping of the various technologies, "now", under a unified .NET Framework 3.0 banner, is a far better measure than it can be any later. This will not only avert another round of marketing confusion in future but also prevent the ever expanding branding namespace from getting further convoluted. After all, haven't we long forgotten the Longhorn for Vista (even though there was so much of brick-batting initially over it)? Plausibly, forgetting demands lesser efforts or time than remembering does.
The fact that .Net framework 3.0 is not introducing anything sour at this stage that will require redesigning or recoding the existing applications, is ostensibly welcome. It, otherwise, could have stirred the development community and their trust. Now that our lives are simplified (or at least are less complicated); bug fixes and fancy enhancements can shortly arrive (as patches/SPs). Similarly, major performance gains can be targeted with every new CPU/architecture release.
The aforesaid concerns and the resultant inertia, to a certain extent, were predictable at the time of announcement of the .Net release 3.0!! So, the ensuing confusion is obvious and is owing to the fact that from the very first release, till thus far; the .Net Framework has primarily grown vertically upwards and its now (with the new 3.0 release) attempting to expand horizontally outwards. This, however, indicates the overall maturity of the platform and is by far a healthy sign. So, instead of remaining dubious anymore, lets wisely step forward to accept the new version as an "additive" release (or more simply put the "production" release of WPF, WCF, WF, and WCS technologies), which is veritably colossal enough to be understated.
Wednesday, August 26, 2009
Remoting
http://www.devx.com/dotnet/Article/7002
Introduction:
Remoting is a means by which one operating system process, or program, can communicate with another process. The two processes can exist on the same computer or on two computers connected by a LAN or the Internet. Communicating between two programs may seem like a big "so what," but it's a rather involved process.
In any operating system, two paramount goals are security and stability. One way to achieve these goals is to load each executing program into its own process. By design, processes are isolated from each other—the code in one process cannot access the code or data of another process. That design enhances security by preventing one program from snooping around where it does not have access rights, and it enhances stability by ensuring that problems in one program cannot inadvertently corrupt the memory space of another program or of the operating system itself. The .NET Framework provides an additional level of isolation with application domains, which permit two or more programs to run within the same process, maintaining the same level of isolation as if they were in separate processes while minimizing the overhead of multiple processes.
Web services are probably the best known type of remoting, but they are not your only option.
While the need for isolation between processes is clear, the fact remains that separate programs sometimes do need to communicate. The emphasis on distributed computing and scalability makes this need even more prevalent today. The .NET Framework provides several method for cross-process communication, collectively called remoting. Web services are probably the best known type of remoting, but they are not your only option. In this article you'll see an overview of .NET remoting technologies that may help you choose between the various remoting options
Marshal by Value or by Reference :
Marshal by value: the server creates a copy of the object passes the copy to the client.
Marshal by reference: the client creates a proxy for the object and then uses the proxy to access the object.
When a client makes a call to an object marshaled by value (MBV), the server creates an exact copy and sends that copy to the client. The client can then use the object's data and executable functionality directly within its own process or application domain without making additional calls to the server. To implement MBV you must either implement the ISerializable interface in your classes, or mark them with the
In contrast, when a client makes a call to an object marshaled by reference (MBR), the .NET framework creates a proxy in the client's application domain and the client uses that proxy to access the original object on the server. To implement MBR a class must, at minimum, extend the System.MarshalByRefObject class. Figure 1 illustrates the differences between MBV and MBR.
Given the differences between MBV and MBR, how do you decide which to use when you're programming a remotable class? In some situations you have no choice—you must use MBR, such as when the remote component must run in its own original app domain, in order to access local files or use operating system handles. These operations could not be carried out by a copy of the object running in the client's app domain. You would also need to use MBR when the client must be made aware of changes in the object. When using MBV the copy of the object that is sent to the client is static, and does not reflect subsequent changes to the state of the object on the server.
In many situations, however, either MBV or MBR will work, and the question is which is better? The concern here is that old bugaboo—bandwidth. Ask yourself which technique places fewer demands on the transport between server and client? With MBV you need move the object copy from the server to the client one time. While that can be a significant task with large objects, after the copy is at the client, calls to it are all within the client's app domain and do not involve the transport mechanism at all.
In contrast, MBR does not require a copy of the entire object to be transported to the client—but each and every time the client accesses the remote object it requires either a one-way or round-trip transport of information. Individually these calls may not place a heavy demand on communication, but hundreds or thousands of calls can add up.
Channels:
HttpChannel: Implements a channel that uses the HTTP protocol.
TcpChannel: Implements a channel that uses the TCP protocol (Transmission Control Protocol).
Both of these classes are dual-purpose in that they implement both a client channel, used on the client side to communicate with remote objects, and a server channel, used on the server side to communicate with clients. The HttpChannel class formats messages using the SOAP protocol, which encodes communications as XML. In contrast the TcpChannel class uses a binary format for messages. While binary formatting is more efficient (formatted messages are smaller), the plain text format of SOAP is much less likely to have problems with firewalls and other network security measures.
When you create a server—that is, a remotable class—you also define and register one or more channels for the class and associate each channel with a specific port. By registering a channel/port combination you tell the .NET infrastructure to listen on that port for messages intended for that channel. When a message arrives, the framework routes it to the correct server object. Figure 2 illustrates how the client and server communicate. Note that when you're using remoting on a single system, the port numbers used by the client and server cannot be the same, because you can use a given port only once.
Demonstration:
This demonstration program presents a simple remoting example. It illustrates the basic tasks involved in creating a remotable class, a server, and a client. To help keep things easy to understand, the demo makes use of .NET command line applications and the command-line compiler, but the same principles apply when you use remoting with other application types. To work with the demo, open a Visual Studio .NET (VS.NET) command prompt from the Start menu by selecting Microsoft Visual Studio .NET, then selecting Visual Studio .NET Tools, and finally Visual Studio .NET Command Prompt. The Command Prompt window opened by this command is like any other Windows command prompt but has the necessary environment and path variables set to let you use the VS.net command line compilers. Create a folder for the project, and make that folder current.
The remotable class (called RemoteClass) contains a single method that returns a "secret" word to the caller. The class constructor displays a console message when a client activates the class. I've included the console message for demonstration purposes only; it's not required for the class to function. Listing 1 shows the source code for the RemoteClass. Note that the only aspect of the class related to remoting is that it inherits from MarshalByRefObject. You can create the demo code using any text editor and then save it in the project folder under the name RemoteClass.cs. Then, from the command prompt, compile the class using the following command (enter the command on a single line):
csc /t:library /debug /r:System.Runtime.Remoting.dll
RemoteClass.cs
The class compiles to the file RemoteClass.dll.
Creates a new TcpChannel on port 8085. Note that this is the same channel on which the client will look for the remotable class.
Registers the channel with the .NET infrastructure.
Registers the remotable class using a call to the RemotingConfiguration.RegisterWellKnownServiceType() method. The arguments to this call are:
The first argument identifies the class being registered.
The second argument specifies the URI for the class. A client will use this URI when looking for the class.
The third argument specifies that if there are multiple calls to the class (from more than one client), they will all be services by the same instance of the class.
Display a message to the user and then pause until the user presses Enter.
Step 4 is required because the server must be executing to do its job. In other words, only while the server program is running will it "listen" for client requests for the remotable class.
To complete the server, save the code from Listing 3 as Server.cs and compile it with the following command line (enter the command on a single line):
csc /debug /r:remoteclass.dll
/r:System.Runtime.Remoting.dll Server.cs
Assuming all three parts of the project compiled successfully, you can test the program as follows.
Open a second Command Prompt window and change to the project folder. You will now have two Command Prompt windows open (the need for this will become clear in a moment).
In one of the windows enter "Server" to execute the server program. It will display the message "Hit
In the other Command prompt window enter "Client" to execute the client program. You'll see two things happen:
The client window displays the message "The secret word is REMOTING", and the client program terminates.
The server window displays the message "MyRemoteClass activated", signaling that a client activated the remote class.
To terminate the server, switch to the server window and press Enter.
You've seen a simple example introducing you to the .NET Framework's remoting capabilities. Given the power of remoting, the relative ease with which you can accomplished it comes as a welcome surprise to many developers. While few real-world scenarios are as simple as the demonstration program presented here, the principles remain the same.
