如何像MNC一样编写公司期望的代码 [英] How to write a code as company expectation like MNC's

查看:124
本文介绍了如何像MNC一样编写公司期望的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Everyone



i参加了很多采访并清除了所有公司的电话回合,但是当我参加机器测试时,最多的公司被告知你的代码是非常基本的水平,你的代码不像2+ exp,但我总是完成他们给出的任务,在我的组织中我只是开发人员,我没有关注的现有项目。实际上我不知道如何用程序方式为C#编写asp.net代码,是否有任何格式升级我的编码,或者是否有任何链接可以参考



这可能不仅对我有帮助,这可能对很多人有帮助所以有没有办法编写代码通常请告诉我



这里是我的编码



 受保护  void  Page_Load( object  sender,EventArgs e)
{
if (! Page.IsPostBack)
{
Session.Clear();
Session.Abandon();
}
}
受保护 void submit_Click( object sender,EventArgs e)
{
username = Request.Form [ 用户名]的ToString();
password = Request.Form [ password]。ToString();

if (connection.State == ConnectionState.Closed)
{
connection.Open();
}

尝试
{
使用(command = new SqlCommand(getsqlstring(),connection))
{

reader = command.ExecuteReader();
while (reader.Read())
{
if (username == reader [ uorgid]。ToString()&& password == reader [ password]。ToString())
{
flag = < span class =code-keyword> true
;
会话[ username] = username.ToString();
Response.Redirect( 〜/ account / home.aspx);
}
}
if (flag == false
{
ScriptManager.RegisterStartupScript( this ,GetType(), alert alert('用户名/密码不匹配'); true );
}
}
}
catch (ThreadAbortException)
{

throw ;

}
最后
{
connection.Close();
command = null ;
}

}

public string getsqlstring()
{
sqlstring = select distinct ud.uorgid,ud.password ,us.compcode来自user_details ud,user_security us其中ud.uorgid = us.userid;
return sqlstring;
}





我需要改进这个编码

解决方案

1。由于存在 SQL注入的风险,切勿将用户的输入直接注入sql语句[ ^ ],阅读:在ASP.Net中验证(检查)数据库中的用户名和密码 [ ^ ]

2.切勿将密码存储为纯文本,阅读:了解和实施密码哈希和腌制的初学者教程 [< a href =http://www.codeproject.com/Articles/608860/Understanding-and-Implementing-Password-Hashingtarget =_ blanktitle =New Window> ^ ]

3.最后但并非最不重要的是,请对您的代码进行评论。


为了改进编码标准,以下基本内容记在你的脑海中

1.你没有写任何正在开发的学校/拼贴作业某种产品所以想想客户的期望,想想最终用户他们可以面对什么样的事情。
2.考虑单元测试用例并计划验证和最终用户消息。
3.考虑其他开发人员和长期维护,根据需要在代码中添加必要的注释,以便在维护或定制时为其他团队成员和您提供帮助。
4.在互联网上搜索某种编码标准,考虑变量和函数名称声明以及代码块使其易于理解,使用Pascal和驼峰套管。
5.始终编写一致且易于理解的代码流。
6.考虑可重用性和短代码。
7.考虑申请表现。
8.在互联网上搜索示例代码并查看/比较您的代码如果可能与您的老年人讨论,两者之间的区别是什么。
9.编码标准可以日复一日地改善,而不是一天的习惯和习惯。

更多请查看以下链接





http://msdn.microsoft.com/en-us/library/ms229042.aspx [ ^ ]





http://blogs.msdn.com/b/brada/ archive / 2005/01/26 / 361363.aspx [ ^ ]





http://msdn.microsoft.com/en-us/library/ff926074.aspx [ ^ ]





http://csharpguidelines.codeplex.com/ [ ^ ]





< a href =http://www.amazedsaint.com/2010/11/top-6-coding-standards-guideline.html> http://www.amazedsaint.com/2010/11/top-6-coding -standards-guideline.html [ ^ ]





http://weblogs.asp.net/lhunt/CSharp-Coding-Standards-document [ ^ ]





http://weblogs.asp.net/lhunt/CSharp-Coding-Standards-document [ ^ ]





http://www.dofactory.com/reference/csharp-coding-standards [ ^ ]





代码审查清单和指南对于C#开发人员 [ ^ ]



C#编码标准和最佳编程实践 [ ^ ]


Hello Everyone

i have attended the lot of interview and cleared the telephonic round in all the companies but when i am attending the machine test rounds maximum companies are told that you code is very basic level and your code is not like 2+ exp ,but i have complete the task always what they given, in my organization i am only the developer, i dont have existing project in my concern . actually i dont know how to write the code in procedural way for asp.net with C#, is there any format for upgrade my coding ,or is there any links to refer

this may be help not only for me,this may help many peoples so is there any way to write code typically please let me know

here is my coding

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Session.Clear(); 
Session.Abandon();
}
}
protected void submit_Click(object sender, EventArgs e)
{
username = Request.Form["username"].ToString();
password = Request.Form["password"].ToString(); 

if (connection.State == ConnectionState.Closed)
{
connection.Open();
}

try
{
using (command = new SqlCommand(getsqlstring(), connection))
{

reader = command.ExecuteReader();
while (reader.Read())
{
if (username == reader["uorgid"].ToString() && password == reader["password"].ToString())
{
flag = true;
Session["username"] = username.ToString();
Response.Redirect("~/account/home.aspx",false);
}
}
if (flag == false)
{
ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Username / Password Not Match');", true);
}
}
}
catch (ThreadAbortException)
{

throw;

}
finally
{
connection.Close();
command = null;
}

}

public string getsqlstring()
{
sqlstring ="select distinct ud.uorgid,ud.password,us.compcode from user_details ud,user_security us where ud.uorgid=us.userid";
return sqlstring;
}



where i need to improve in this coding

解决方案

1. Never inject user's inputs directly into sql statement due to risk of SQL Injection[^], read: Validating (Check) Username and Password from database in ASP.Net[^]
2. Never store password as plain text, read: A Beginner's Tutorial for Understanding and Implementing Password Hashing and Salting[^]
3. Last but not least, do comment your code.


For improving coding stander's following basic things keep in your mind 

1. You are not writing any school / collage assignment you are developing some kind of product so think about the client expectation’s, think about the end user what kind of things they can be face.
2. Think about unit test case and plan validations and end user messages.
3. Think for other developer and long term maintenance, put necessary commenting in the code as required that will be help for other team members and also to you at the time of maintenance or customization.
4. Search some kind of coding stander on the internet, think about variable and function name declaration and code blocks make it understandable, use Pascal and camel casing.
5. Always write consistent and understandable flow of code.
6. Think about the re-usability and short line of code.
7. Think about performance of application.
8. Search sample code on the internet and review / compare with your code what is the difference between both if possible discuss with your seniors also.
9. Coding stander can be improve day by day not in a day it is some kind of habit and practice.

for more please check following links



http://msdn.microsoft.com/en-us/library/ms229042.aspx[^]


http://blogs.msdn.com/b/brada/archive/2005/01/26/361363.aspx[^]


http://msdn.microsoft.com/en-us/library/ff926074.aspx[^]


http://csharpguidelines.codeplex.com/[^]


http://www.amazedsaint.com/2010/11/top-6-coding-standards-guideline.html[^]


http://weblogs.asp.net/lhunt/CSharp-Coding-Standards-document[^]


http://weblogs.asp.net/lhunt/CSharp-Coding-Standards-document[^]


http://www.dofactory.com/reference/csharp-coding-standards[^]


Code Review Checklist and Guidelines for C# Developers[^]

C# Coding Standards and Best Programming Practices[^]


这篇关于如何像MNC一样编写公司期望的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆