关于提高代码质量的观点

今天在项目讨论中有个话题是如何提升代码质量,简单介绍一下我的观点:

1) 代码风格应该易读易懂,从这个角度来说,过于复杂的LINQ,过长的函数,复杂的判断条件,超长的三元表达式都违背了这个原则,如果代码作者在review时需要很长时间去解释某个函数,应该需要通过注释/需求文档来补充,这段解释应该形成文字。

2)  使用工具而不是靠人品保证某些基本的规则,有没有把project setting的代码分析选项打开?有没有使用最高的标准,类似下面这种简单的警告有没有顺手fix的习惯,加入代码有没有要求人review的习惯,fix defect是否添加了足够的测试用例,有没有试图在本地跑一跑Sonar检查。如果用时间紧项目复杂作为理由,这些的确都算说得过去,但也都可以挤出时间来做,不需要非得什么特定时间。(对于进入产品环境的项目,有另外的要求)

3)  任何时间,代码质量和任务进度都需要权衡,测试时间越多,自动测试用例越多,那当然是越好,但我们作为GDC,其实任务完成量也很重要。我们需要找到一个比较好的平衡点,不在测试上和UnitTest过多投入,也不是过分追求进度忽视质量,这也是我建议大家尽量多写自动UnitTest的原因,随着项目进行,这种投入产出会变得越来越值得,尤其是针对我们这种开发时间比较长的项目,否则我们只能增加手动测试时间,反而得不偿失。

NDCOslo2013技术视频链接

比较自由的技术大会,偏向于微软系。


Russ Miles: You are not (only) a software developer! – Simplicity in practice


Torstein Nicolaysen: All you need to know about TypeScript


Scott Meyers: Better Software — No Matter What


Dan North: Patterns of Effective Teams


Alvaro Videla: Cloud Messaging with Node.js and RabbitMQ


Don Syme: Succeeding with Functional-first Programming in Industry


Allan Kelly: Do it right, then do the right thing


Tom Dale, Peter Cooper and Rob Conery; Cage Match – EmberJS vs. Angular


Pedro Félix: From requests to responses: a journey into the ASP.NET Web API runtime architecture


Scott Allen: The Abstractions of AngularJS


Robert C. Martin: Clean Architecture and Design


Benjamin Mitchell: Effective Leadership: How to avoid anti-learning Agile advice


Michael Heydt: Concurrent and High-Performance Programming in .NET with TPL, async/await, and Dataflow


Scott Guthrie: Building Real World Cloud Apps with Windows Azure – Part 1


Jeff French: Continuously Deploying Complex Apps Doesn’t Have to Suck!


Don Syme: Making Magic: Combining Data, Information, Services and Programming, at Internet-Scale


Dan North: Accelerating Agile: hyper-performing teams without the hype


Simon Skov Boisen: Building clean and cohesive concurrent systems with F# agents


Sebastiano Armeli Battana: Require JS


Jon McCoy: Hacking .NET(C#) Application: An Unfriendly Territory


Kevlin Henney: Functional Programming You Already Know


Rob Conery: The Javascript Inferno – A Decent Into the Client-side MVC Netherworld


Ram Yoga: All projects should do usability testing!


Jon Skeet: Abusing C#


Venkat Subramaniam: Asynchronous Programming on the .NET Platform


Liz Keogh: Don’t let your process hide your ignorance


Jon McCoy: Hacking .NET(C#) Application: Code of the Hacker


Fredrik Kalseth: UX by Developers


Kevlin Henney: The Architecture of Uncertainty


Gojko Adzic: Make Impacts, Not Software


Niall Merrigan: Defensive Programming 101 v3


Bryan Hunter: Erlang: a jump-start for .NET developers


Richard Campbell: People, Process, Tools – The Essence of DevOps


Neal Ford: Information Alchemy: Presentation Patterns (& Anti-patterns)


Tim G. Thomas: A Developer’s Guide to Design Frameworks (and More!)


Jon Skeet, Rob Conery: Tekpub’s Full Throttle! Live on Stage with Jon Skeet


Magne Jørgensen, Stein Grimstad: How much is a great developer worth?


James Shore: Rigorous, Professional JavaScript


Gill Cleeren: Applied MVVM in Windows 8 apps: not your typical MVVM session!


Miguel Castro: Doing SPA with MVC & KnockoutJS


Andy Hunt: Mining your Creativity Mind


Ian Cooper: TDD, where did it all go wrong


Robert Reppel: Rigging Plan B: How To Go Live Safely With Bubbles, Domain Toggles And Obsessive Monitoring


Stuart Halloway: Introduction to Clojure


Stuart Lodge: Sharing C# across Windows, Android and iOS using MvvmCross


Venkat Subramaniam: Succeeding with TDD: Pragmatic Techniques for effective mocking


August Lilleaas: Service oriented architectures (hardcore separation of concerns)


Kristian Hellang, Justin Rusbatch: Exploring the C# Scripting Experience with scriptcs


James Shore: Test-Driven JavaScript Master Class


Giovanni Asproni: Writing Usable APIs in Practice


Christian Horsdal: Test Driving Nancy


Stuart Halloway: Simulation Testing


Andy Hunt: Debugging your mind


Craig Dunn: iOS with C# using Xamarin


Jon Arild Tørresdal: Continuously Deliver with ConDep


Torstein Bjørnstad: Building Third-party Widgets and APIs using JavaScript


Mark Seemann: Big Object Graphs Up Front


Katya Mustafina: Value of unit test: way from good design to easy maintenance


Chris Hardy: Real Cross-platform Mobile Applications – The Anti-Pattern


Scott Meyers: Better Software — No Matter What


Jimmy Bogard: Holistic testing


Jon Skeet: C# 5


.NET Rocks – Functional Programming Panel: Type systems and static typing – saving your ass or getting in your face


Jonas Winje, Einar W. Høst, Bjørn Einar Bjartnes: Reactive meta-programming with drones


Mark Seemann: Faking Homoiconicity in C# with graphs


Erling Wegger Linde: Chef for developers


Iris Classon: Live coding: The Windows Store Apps showdown – C# vs JavaScript


Kim Joar Bekkelund: Patterns of large-scale JavaScript applications