Showing posts with label Development. Show all posts
Showing posts with label Development. Show all posts

Aug 31, 2014

Robert C. Martin (Uncle Bob) - Demanding Professionalism in Software Development

http://www.youtube.com/watch?v=p0O1VVqRSK0

Professional expectations - how we will behave:

  • We will not ship shit.
  • We will always be ready. Ready to deploy/ship/execute all the time. Not all features may necessarily be done. Code gets checked in = ready to deploy.
  • Stable productivity. Keep the feature delivery rate constant. Start project fast and keep the pace. Keep the code clean.
  • Inexpensive adaptability. Customers always change their mind. Design for change.
  • Continuous improvement. Keep everything continuously clean and working. No "full system redesign". Boy scout rule - "keep/leave the campground cleaner than when you found it".
  • Fearless competence. There exists a fear of touching code that may break the system. When you see something in the code that is wrong, clean it, instantly, without fear, without hesitation. E.g.: TDD way.
  • Extreme quality.
  • QA will find nothing. QA should wonder why they are there and it's our job to make them worried about that.
  • We cover for each other. We're a team. If a member disappears, the rest of the team will be able to make progress. Become familiar with other people's code. E.g.: pair programming.
  • Honest estimates. The most honest estimate - "I don't know". Real estimate is a range that defines the uncertainty of the estimate. Keep constant updates on the estimates as work progresses. A specific date is a lie, a range is the truth.
  • You will say "No". Never say "I will try".
  • Automation! Automate your test scripts, your build scripts, your deployment scripts, etc.
  • Continuous aggressive learning.
  • Mentoring.

Jul 12, 2012

MVC Html helper values and ModelState

Surprisingly, if you do a return View(model); in your postback action, the @Html.EditorFor helper does not use the values from the passed model, but the values from the ModelState are used instead. Supposedly for form input persistence reasons, but does not make sense to me since you explicitly pass on the model. To still use the html helpers and the model, you can clear the ModelState first in your action: ModelState.Clear();

 

May 15, 2012

Mercurial repository migration

Can be used to move a folder from one repository into its own repository. E.g.:
hg convert --filemap migrationMap "C:\Dev" "c:\src\MyProject"

 

migrationMap is a file with:
include MyProject
rename MyProject .

May 8, 2012

Certificate access permissions

In Windows Resource Kit there is a utility winhttpcertcfg.exe.

List certificate key permissions:
winhttpcertcfg.exe -l -c LOCAL_MACHINE\My -s "certificate.name"

 

Grant permissions to a certificate key:
winhttpcertcfg.exe -g -c LOCAL_MACHINE\My -s "certificate.name" -a WindowsAccount

 

Grant account permissions to run as a Windows service:
Logon as service policy

 

Grant account permissions to run as an ASP.NET application service:
aspnet_regiis -ga WindowsAccount

 

Give WindowsAccount write permissions to C:\Windows\Temp

If the certificate is not in this store and you want to move it there from another location, you must export the certificate and then import it. Do not drag and drop it in the Certificates MMC UI or it won't work.

Feb 4, 2011

Serialize and Deserialize object to DB / XElement


//To serialize into XElement:

        XmlSerializer x = new XmlSerializer(typeof(ComplexType));
        XDocument doc = new XDocument();
ComplexType ct = _getComplexType();
using (XmlWriter xw = doc.CreateWriter())
{
ComplexType ct = _getComplexType();
x.Serialize(xw, complexType);
xw.Close();
}
XElement el = doc.Root;

//To deserialize into ComplexType:

        using (XmlReader xr = el.CreateReader())
        {
            ComplexType deserializedComplexType =
x.Deserialize(xr) as ComplexType;
            xr.Close();
        }

Feb 3, 2011

Exposing unreferenced data types via WCF service

For example, need to expose an enumeration that is not used by any of the WCF service operations to the client (via WSDL).

While ServiceKnownType attribute on the service class/interface/method exposed the type in the XSD schema of the WSDL, the default client proxy generation does not generate code for it.

Eventually ended up with a dummy solution of having a dummy method:


public class ExposedDataTypes
{
public CustomType1 type1 { get; set; }
public CustomType2 type2 { get; set; }
}



ExposedDataTypes IService.Ignore()
{
return null;
}


Not the best solution, but couldn't gracefully work around it. Easy and works nicely though.

Jan 31, 2011

WCF Service over HTTPS / SSL with basicHttpBinding


  1. In IIS, set "Require secure channel (SSL)" option for the site / virtual directory.

  2. In web.config, set <bindings><basicHttpBinding><binding...><security mode="Transport">.

  3. In web.config, set <system.serviceModel><behaviors><serviceBehaviors><behavior...><serviceMetadata httpsGetEnabled="true"/>

Jan 19, 2011

.NET System.Diagnostics.Stopwatch may be wrong

The .NET System.Diagnostics.Stopwatch timer is a software based timer and it will not count while device is in sleep mode as CPU is not running. Only less accurate real time clock will keep running.

Found this when timing a long web service call. Suppose this is the case for operations not using full CPU ticks.

Example code:

Console.WriteLine("start...");
var sw = System.Diagnostics.Stopwatch.StartNew();
System.Threading.Thread.Sleep(5000);
sw.Stop();
Console.WriteLine(string.Format("Elaped: {0} ({1} ms)", sw.Elapsed, sw.ElapsedMilliseconds));


May results in something like:

start...
Elaped: 00:00:02.3029859 (2302 ms)