Blog Home  Home Feed your aggregator (RSS 2.0)  
Software Code Help - Thursday, November 19, 2009
Blog
 
# Thursday, November 19, 2009

Here are several techniques for achieving good coding practices that are less heavy-handed than laying down rigid coding standards:

 

Assign two people to every part of the project

 

If two people have to work on each line of code, you’ll guarantee that at least two people think it works and is readable. The mechanisms for teaming two people can range from pair programming to mentor-trainee pairs to buddy- system reviews.

 

Review every line of code

 

A code review typically involves the programmer and at least two reviewers.  That means that at least three people read every line of code. Another name for  peer review is “peer pressure.” In addition to providing a safety net in case the original programmer leaves the project, reviews improve code quality because the programmer knows that the code will be read by others. Even if your shop hasn’t created explicit coding standards, reviews provide a subtle way of moving toward a group coding standard—decisions are made by the group during reviews, and, over time, the group will derive its own standards.

 

Require code sign-offs

 

In other fields, technical drawings are approved and signed by the managing  engineer. The signature means that to the best of the engineer’s knowledge, the  drawings are technically competent and error-free. Some companies treat code the same way. Before code is considered to be complete, senior technical personnel must sign the code listing.

 

Route good code examples for review

 

A big part of good management is communicating your objectives clearly. One way to communicate your objectives is to circulate good code to your programmers or post it for public display. In doing so, you provide a clear example of the quality you’re aiming for. Similarly, a coding-standards manual can consist mainly of a set of “best code listings.” Identifying certain listings as “best” sets an example for others to follow. Such a manual is easier to update than an English-language standards manual and effortlessly presents subtleties in coding style that are hard to capture point by point in prose descriptions.

 

Emphasize that code listings are public assets

 

Programmers sometimes feel that the code they’ve written is “their code,” as if it were private property. Although it is the result of their work, code is part of the project and should be freely available to anyone else on the project that needs it. It should be seen by others during reviews and maintenance, even if at no other time.

One of the most successful projects ever reported developed 83,000 lines of code in 11 work-years of effort. Only one error that resulted in system failure was detected in the first 13 months of operation. This accomplishment is even more dramatic when you realize that the project was completed in the late 1960s, without online compilation or interactive debugging. Productivity on the project, 7500 lines of code per work-year in the late 1960s, is still impressive by today’s standards. The chief programmer on the project reported that one key to the project’s success was the identification of all computer runs (erroneous and otherwise) as public rather than private assets (Baker and Mills 1973). This idea  has extended into modern contexts including Extreme Programming’s idea of collective ownership (Beck 2000), as well as in other contexts.

 

Reward good code

 

Use your organization’s reward system to reinforce good coding practices. Keep these considerations in mind as you develop your reinforcement system:  

  • The reward should be something that the programmer wants. (Many programmers find “attaboy” rewards distasteful, especially when they come from nontechnical managers.)
  • Code that receives an award should be exceptionally good. If you give an award to a programmer everyone else knows does bad work, you look like Charlie Chaplin trying to run a cake factory. It doesn’t matter that the programmer has a cooperative attitude or always comes to work on time. You lose credibility if your reward doesn’t match the technical merits of the situation. If you’re not technically skilled enough to make the good-code judgment, don’t! Don’t make the award at all, or let your team choose the recipient.

 

One easy standard

 

If you’re managing a programming project and you have a programming background, an easy and effective technique for eliciting good work is to say “I  must be able to read and understand any code written for the project.” That the manager isn’t the hottest technical hotshot can be an advantage in that it may discourage “clever” or tricky code.

Thursday, November 19, 2009 11:36:40 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]   General  | 
  1. Separation of Code from HTML
    To make a clean sweep, with ASP.NET you have the ability to completely separate layout and business logic. This makes it much easier for teams of programmers and designers to collaborate efficiently. This makes it much easier for teams of programmers and designers to collaborate efficiently.
  2. Support for compiled languages
    developer can use VB.NET and access features such as strong typing and object-oriented programming. Using compiled languages also means that ASP.NET pages do not suffer the performance penalties associated with interpreted code. ASP.NET pages are precompiled to byte-code and Just In Time (JIT) compiled when first requested. Subsequent requests are directed to the fully compiled code, which is cached until the source changes.
  3. Use services provided by the .NET Framework
    The .NET Framework provides class libraries that can be used by your application. Some of the key classes help you with input/output, access to operating system services, data access, or even debugging. We will go into more detail on some of them in this module.
  4. Graphical Development Environment
    Visual Studio .NET provides a very rich development environment for Web
    developers. You can drag and drop controls and set properties the way you do in Visual Basic 6. And you have full IntelliSense support, not only for your code, but also for HTML and XML.
  5. State management
    To refer to the problems mentioned before, ASP.NET provides solutions for session and application state management. State information can, for example, be kept in memory or stored in a database. It can be shared across Web farms, and state information can be recovered, even if the server fails or the connection breaks down.
  6. Update files while the server is running!
    Components of your application can be updated while the server is online and clients are connected. The Framework will use the new files as soon as they are copied to the application. Removed or old files that are still in use are kept in memory until the clients have finished.
  7. XML-Based Configuration Files
    Configuration settings in ASP.NET are stored in XML files that you can easily read and edit. You can also easily copy these to another server, along with the other files that comprise your application.
Thursday, November 19, 2009 10:27:53 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Interview Question ASP.NET  | 
# Wednesday, November 11, 2009

STA (Single Threaded Apartment) is basically the concept that only one thread will interact with your code at a time. Calls into your apartment are marshaled via windows messages (using a non-visible) window. This allows calls to be queued and wait for operations to complete.

MTA (Multi Threaded Apartment) is where many threads can all operate at the same time and the onus is on you as the developer to handle the thread security.

Wednesday, November 11, 2009 4:34:46 AM (GMT Standard Time, UTC+00:00)  #    Comments [0]   Interview Question .Net  | 
# Tuesday, October 20, 2009

The .NET Framework uses role-based security and code-based security mechanisms for protecting resources and code from unauthorized use. Click each security mechanism to learn more:

Role Based Security
--------------------
A role-based security model uses authenticated identity information about the user to determine which computing resources the user is authorized to use. The authenticated identity information typically consists of the user’s logon and the roles that are associated with the user. Role-based security in the .NET Framework also allows developers to use Microsoft Windows® user and group information, or to perform custom authentication and authorization by using generic principals and identities.

A role defines a group of related users of an application. For example, a banking application may impose limits on the withdrawal amounts that can be transacted, based on role. In this scenario, tellers may be authorized to process withdrawals that are less than a specified amount, whereas managers may be allowed to process withdrawals above the amount specified. Role-based security in the .NET Framework extensively uses two concepts: identities and principals.

An identity encapsulates the user’s logon name.
A principal encapsulates the membership information of the user’s role.
The runtime provides functionality to perform authorization checks by using identity and principal-related objects directly, or by using imperative or declarative permission checks. .NET Framework role-based security supports authorization by making information about the user, which is constructed from an associated identity, available to the current thread. The identity can be based on a Windows account, or it can be a custom identity unrelated to a Windows account.

Code based Security
-------------------
Code access security is a mechanism provided by the CLR to examine and enforce permissions granted by security policy. To prevent unintended code paths from exposing a security vulnerability, all callers on the call stack must be granted the necessary permissions.

Every application that targets the CLR must interact with its security system. When an application runs, it is automatically evaluated and given a set of permissions by the CLR. Depending on the permissions that the application receives, it either runs properly or generates a security exception. The local security settings on a particular computer ultimately decide which permissions the code receives.

 

Tuesday, October 20, 2009 7:37:22 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0]   Interview Question .Net  | 

Process-per-client Architecture.
Multithreaded Architecture.
Hybrid Architecture.

Tuesday, October 20, 2009 7:10:59 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0]   Interview Question SQL | SQL Server  | 
# Wednesday, October 07, 2009

A shallow copy creates a new instance of the same type as the original object, and then copies the non-static fields of the original object. If the field is a value type, a bit-by-bit copy of the field is performed. If the field is a reference type, the reference is copied but the referred object is not; therefore, the reference in the original object and the reference in the clone point to the same object.

A deep copy of an object duplicates everything directly or indirectly referenced by the fields in the object

Wednesday, October 07, 2009 7:19:22 AM (GMT Daylight Time, UTC+01:00)  #    Comments [1]   C# | Interview Question .Net  | 
# Sunday, October 04, 2009

First Download IE Web Control from this location.

http://www.asp.net/downloads/archived/ie-web-controls/IEWebControls.exe
 
To build the IE Web Controls:

1.  Make sure you have installed the .NET Framework SDK v1.0 or v1.1
2.  Run Build.bat, which will create a build folder in this directory. 
    The build folder contains Microsoft.Web.UI.WebControls.dll and a
    Runtime directory of supporting files.

To run the IE Web Controls:

1.  Copy the contents of the Runtime directory to the webctrl_client\1_0
    directory under your top-level site directory.  For example, if your
    site root is c:\Inetpub\wwwroot, type this at the command prompt:

    IE Installable Path>xcopy /s /i .\build\Runtime c:\Inetpub\wwwroot\webctrl_client\1_0 /y

    This will create the following directory structure under the site:

      /webctrl_client/1_0
        MultiPage.htc
        TabStrip.htc
        toolbar.htc
        treeview.htc
        webservice.htc
        webserviced.htc
        [images]
        [treeimages]

2.  Create a new web application in IIS and copy the contents of the
    samples directory to this application directory.  For example:

    xcopy /s /i .\samples c:\Inetpub\wwwroot\sampleapp /y

3.  Create a /bin subdirectory for the application and copy the file
    Microsoft.Web.UI.WebControls.dll to this directory.

    The contents of the application will be as follows:

      /sampleapp
        multipage.aspx
        state_city.xml
        tabstrip.aspx
        toolbar.aspx
        treeview.aspx
        treeview_bound.aspx
        /bin
          Microsoft.Web.UI.WebControls.dll

4.  Request the sample pages from your Internet Explorer web browser, for
    example: http://localhost/sampleapp/multipage.aspx
   
For additional documentation and samples visit:
http://msdn.microsoft.com/library/default.asp?url=/workshop/webcontrols/webcontrols_entry.asp

Sunday, October 04, 2009 7:36:15 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0]   asp.net  | 
# Tuesday, September 29, 2009

For Example:

Number Value.....
1          AD
2          GD
2          DE
3          IF
4          OG
4          JD

The output I would like is:-

1         AD
2         GD,DE
3         IF
4         OG,JD

You can also resolve this problem using function.

Create Function Concat( @iNumber int )
RETURNS varchar(500)
AS
BEGIN
 
   DECLARE @List varchar(500)
   SET @List = ''
   Select @List = @List + strValue + ',' from Testing
   Where Number = @iNumber
   RETURN LEFT(@List,LEN(@List)-1)
End

And use this function in SQL Query.

select Number, dbo.Concat(Number) from Testing Group By Number

Tuesday, September 29, 2009 3:46:35 AM (GMT Daylight Time, UTC+01:00)  #    Comments [1]   SQL Server  | 
# Tuesday, August 11, 2009
In case, when you are facing colspan problem in datagarid paging section, then use this code to correcting colspan problem.
 
protected void dGrid_PreRender(object sender, EventArgs e)
        {
            try
            {
                DataGrid dgSidDetails = (DataGrid)sender;
                //Fix for numbering being in a left aligned column
                //For some reason, the ColumnSpan property is ignored andnot rendered
                    //unless set using the Attributes
                    if (dgSidDetails.AllowPaging == true && dgSidDetails.AutoGenerateColumns ==    false)
                    {
                        //Get the Table
                        System.Web.UI.WebControls.Table tab =
                            (System.Web.UI.WebControls.Table)dgSidDetails.Controls[0];
                        //Change the Top Pager
                        if (dgSidDetails.PagerStyle.Position == PagerPosition.Bottom ||
                            dgSidDetails.PagerStyle.Position == PagerPosition.TopAndBottom)
                        {
                            tab.Rows[tab.Rows.Count -
                                1].Cells[0].Attributes.Add("colspan",
                                tab.Rows[1].Cells.Count.ToString());
                        }
                        //Change the Bottom Pager
                        if (dgSidDetails.PagerStyle.Position == PagerPosition.Top ||
                            dgSidDetails.PagerStyle.Position == PagerPosition.TopAndBottom)
                        {
                            tab.Rows[0].Cells[0].Attributes.Add("colspan",
                                tab.Rows[1].Cells.Count.ToString());
                        }
                    }
            }
            catch (Exception ex)
            {

            }
        }
Tuesday, August 11, 2009 12:29:41 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0]   Interview Question ASP.NET  | 
# Friday, August 07, 2009
SELECT COUNT(*) AS Total FROM syscolumns WHERE (name = 'clientID')
Friday, August 07, 2009 12:34:54 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0]   Interview Question SQL  | 
Copyright © 2010 SoftwareCodeHelp. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: