Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • Naming conventions while writing code

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 77
    Comment on it

    While building applications and writing codes, you have to understand that conventions needs to be followed.

     

    Two main things are used while writing codes.

    1 Camel Casing

    2  Pascal Casing

     

     

    Camel casing as the figure suggests that you need to define the things like the first letter of the word should be in capital and the first letter of second word and after should also be in small.

     

    While writing or defining variables you need to follow the camel casing .

     

    Pascal casing means first letter of the word should be small and the second word first letter should be capital.

     

     public class ProductRepository
        {
            #region "==== Connection String ===="
            -- Pascal Casing --
            private String connectionString = ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString;
            #endregion
    
    
            public ProductResponse GetProduct()
            {
                List<ProductModel> lstModel = new List<ProductModel>();
                          
               -- Camel Casing--
               ProductResponse ProductResponse = new ProductResponse();
                try
                {
                    SqlDataReader reader = null;
                    using (SqlConnection sqlConnection = new SqlConnection(connectionString))
                    {
                        if (sqlConnection.State == ConnectionState.Closed)
                        {
                            sqlConnection.Open();
                        }
                        reader = SqlHelper.ExecuteReader(sqlConnection, CommandType.StoredProcedure, "uspGetNudgeLocations");
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                lstModel.Add(new ProductModel
                                {
                                    Id = reader["ProductId"] != null ? !string.IsNullOrEmpty(Convert.ToString(reader["ProductId"])) ? Convert.ToInt32(Convert.ToString(reader["ProductId"]).Trim()) : 0 : 0,
                                    ProductName = reader["ProductName"] != null ? Convert.ToString(reader["ProductName"]).Trim() : string.Empty
                                });
                            }
                        }
    
                        else
                        {
                            lstModel.Add(new ProductModel
                            {
                                ProductName = "No Product Found"
                            });
                        }
                    }
    
                    ProductResponse.ProductList = lstModel;
                    ProductResponse.Status = true;
                }
    
                catch (Exception ex)
                {
                    ProductResponse.Message = ex.Message;
    
                    ProductResponse.Status = false;
                }
                return ProductResponse;
            } 
        }

     

    .net

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: