Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
D

Dominic Pettifer

@Dominic Pettifer
About
Posts
75
Topics
28
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Why nHibernate [modified]
    D Dominic Pettifer

    I'm still not sure what UX and Task Oriented Design have got to do with an Object Relational Mapper, a thing meant to make it easier to query a database in code. And how does manually writing RAW ADO.NET code, inline SQL statements and tons of Sprocs leads to better UX? Saying an ORM leads to bad UX is like saying Homosexuality leads to earthquakes :-)

    Dominic Pettifer Blog: www.dominicpettifer.co.uk

    The Lounge question csharp c++ java career

  • Why nHibernate [modified]
    D Dominic Pettifer
    1. Bad UI has got absolutely nothing to do with an ORM, and everything to do with a bad designer, or developer with no design/UI skills being made to do design/UI work, or numerous other reasons, but nothing to do with an ORM. 2) NHibernate DOES NOT code generate a complete application for you, just the database access code, and even if you have a nice task oriented UI, you still have to hit a database table at some point, and NHibernate makes that easier. 3) Nhibernate doesn't just map one table to one class, it has quite sophisticated mapping capabilities, such as inheritence mapping, component mapping (think Address object inside Customer class, but Customer table uses separate fields for Address etc.), mapping many-to-many relations, mapping obscure types such as enums, collections of strings etc. You can quite easily apply Domain Driven Design principle (Aggregates, Aggregate Roots etc.) as well, so you get a nice semantic Object Oriented model of your data, instead of a Relational Oriented one.

    Dominic Pettifer Blog: www.dominicpettifer.co.uk

    The Lounge question csharp c++ java career

  • ORM: found this.
    D Dominic Pettifer

    The whole reason you use an ORM is for the productivity and maintainability enhancements, not performance. Honestly, just buying a slightly faster CPU or more RAM is cheap compared to the costs of hiring expensive top tier developers. If you’re building a large enterprise application it can be hard and laborious to write potentially 1000’s of SQL strings and raw ADO.NET code strewn all over the codebase. An ORM lets you take advantage of the power of your Object Oriented Programming language to define rich domain models, that communicate your business domain more clearly than what you can do with just having a bunch of SQLCommand’s and SqlConnections and SqlDataReaders all over the place. You might want to read up on something called Domain Driven Design (http://en.wikipedia.org/wiki/Domain-driven\_design), which is essentially what I’m describing. Honestly, I’d rather write:

    Category category = CategoryRepository.FromId(categoryId);
    IList<Product> products = category.Products;

    ...than trying to write the equivalent in RAW ADO.NET/SQL which would probably be dozens of lines of code long, and I bet the performance difference could barely be measured in milliseconds, a performance degradation that could easily be recouped by spending an extra £100 on a slightly faster CPU vs. spending potential thousands on extra contractors to maintain your 1000’s line of ADO.NET/SQL code all over your codebase. Also the above code communicates the design of this system more clearly than the equivalent ADO.NET code. Though some ORMs have constraints, most are very flexible, for instance Linq 2 SQL and NHibernate let you map actual Stored Procedures if you need to perform a complex query that can’t be done by the ORM, but 90% of the time I’m writing relatively simple queries that can.

    Dominic Pettifer Blog: www.dominicpettifer.co.uk

    modified on Thursday, July 1, 2010 5:05 AM

    The Lounge csharp com performance question career

  • E-book Reader Should I buy One
    D Dominic Pettifer

    I'd say either an iPad, or if you don't like the restrictive iPhone OS, wait for the HP Slate PC coming in June, which is basically a Windows 7 iPad. I'm considering the HP Slate route though I only hope (pray) that it doesn't suck. The reason I'd go for one of those two is because they're in colour, Amazon Kindle DX isn't even though it can handle technical PDFs quite well, and quite a few technical computer books use colour, especially the designy ones on HTML, CSS, Silverlight etc.

    Dominic Pettifer Blog: www.dominicpettifer.co.uk

    The Lounge com question learning

  • Interviewing / candidate qualifying tips
    D Dominic Pettifer

    Despite the negative comments towards John Simmons, I think I have to agree with him. Any professional developer who cares about their profession and is good at it will own their own development environment (doesn't have to be a laptop, could be a desktop). Also they would be able to provide their own code samples that they made outside of work, yes, as in they wrote code in their own spare time. It's no different in any other skilled profession, a highly skilled builder would likely have their own set of building tools at home, would have worked on their own building projects, such as building an extension to their house, or even a shed, a patio, or some sort of room conversion. A doctor would probably have their own medical books, and study up on the latest medical trends/research papers in their own time. It's continuous self improvement, and it's necessary in most highly skilled professions, especially one like software engineering that is constantly evolving. In my experience the best programmers are the ones who program in their free time as a hobby, or just as a professional courtesy to keep their skills up to date. And the worst are the ones who see programming as just a 9 - 5 job, and would only bother learning a new skill set when they are required too (eg. by an employer). I honestly can't comprehend the opinions of people who would avoid hiring programmers who program in their free time, that seems absurd to me, I would go out of way to hire those people. I can make an exception for people in poorer countries where owning your own computer is prohibitively expensive. But if I was in that situation, I would try to find ways around the problem, use computers/books in the library, ask my employer if I take my computer home each day etc.

    Dominic Pettifer Blog: www.dominicpettifer.co.uk

    The Lounge csharp asp-net database sql-server winforms

  • Deep Zoom - Generate on Demand/Dynamically
    D Dominic Pettifer

    Is there a way to generate a Deep Zoom image dynamically on demand, from a bunch of images contained on a web server, in a Silverlight application? Say I have a list of 400 URLs to images that I get from a database, which vary based on user input, and I want to create a Deep Zoom image by stitching all those other images together in say a 20x20 grid (400 total). Is it possible to do this in Deep Zoom, or will I need to write my own implementation. From what I've read of Deep Zoom this isn't possible, it's only good for displaying an image that was manually created (via Deep Zoom Composer) ahead of time, rather than on demand. But I obviously want to double check this before I go off and create my own 2D grid of elements, implement my own zoom via RenderTransform etc.

    Dominic Pettifer Blog: www.dominicpettifer.co.uk

    WPF php css database sysadmin question

  • Exchange Rate/Currency Conversion Web Service (SOAP/REST/RSS) Suggestions?
    D Dominic Pettifer

    How do they compare to these people www.xe.com [^]? They seem to be a bit cheaper ($540 per year vs. $200 per month).

    Dominic Pettifer Blog: www.dominicpettifer.co.uk

    IT & Infrastructure wcf xml com json question

  • Exchange Rate/Currency Conversion Web Service (SOAP/REST/RSS) Suggestions?
    D Dominic Pettifer

    Hi, Can anyone recommend companies that offer Currency Conversion web services (via SOAP, REST, RSS, XML etc.). We don't mind paying for it (although free would be good as well), we just need it to be reliable. I know I can search on google.com and find 100s of companies offering this, but I don't know which one to choose so was wondering if people had any recommendations, or experience of companies they've used in the past. Many thank!

    Dominic Pettifer Blog: www.dominicpettifer.co.uk

    IT & Infrastructure wcf xml com json question

  • VS2008 - Web "Project" referenced by other Web"sites" in same solution
    D Dominic Pettifer

    Hi, I'm not entirely sure this is possible, but I want to have a single web "project" (not site) to act as a kind of library of WebControls and UserControls which can then be used by other web_site_ projects contained in the same solution, rather then keep multiple copies of those WebControls in each website, defeating the purpose of code reuse. I know this is easily possible for Server/Custom controls since they are just pure class files (just put them in a separate assembly). However, Web/User Controls consist of an .ascx file with a .cs/vb code behind, how would this get copied across? Many thanks!

    Dominic Pettifer Blog: www.dominicpettifer.co.uk

    Visual Studio winforms sysadmin question

  • Linq to SQL - Writing a generic "GetObjectFromId" method
    D Dominic Pettifer

    I'm trying to write a generic Ling to SQL GetObjectById() method for getting a data object from the database based on a primary key id value, so that instead of having to write... MyDataContext dataContext = new MyDataContext(); Product myProduct = dataContext.Products.SingleOrDefault<Product>(p => p.Id == productId); ...I instead write... Product myProduct = Product.FromId(productId); ...which I think is much cleaner. Now I could simply write individual 'FromId' methods in each mapped data class, but where's the fun in that. So I tried to write a more generic one size fits all method for doing this and came up with the following...

    public abstract class BaseTable<T>
    {
    public static T FromId(int id)
    {
    MyDatabaseDataContext dataContext = DatabaseContextHelper.GetDatabaseContext();

        StringBuilder sql = new StringBuilder();
        sql.Append("SELECT ");
    
        MetaTable metaTable = dataContext.Mapping.MappingSource.GetModel(typeof(TopicDatabaseDataContext))
                                        .GetMetaType(typeof(T)).Table;
    
        foreach (MetaDataMember dm in metaTable.RowType.DataMembers)
        {
            if (dm.DbType != null)
            {
                sql.Append(dm.MappedName).Append(",");
            }
        }
    
        sql.Remove(sql.Length - 1, 1);
    
        sql.Append(" FROM ").Append(metaTable.TableName).Append(" WHERE Id = ").Append(id);
    
        return dataContext.ExecuteQuery<T>(sql.ToString()).FirstOrDefault<T>();
    }
    

    }

    I need to ensure all the mapped data classes extend BaseTable<T> but this does seem to work, however, I was wondering if this was the best way of doing this. Wouold this method create any problems, and is there a more efficient way of doing it. I know this is probably overkill just so I can go from dataContext.Products.SingleOrDefault<Product>(p => p.Id == productId) to Product.FromId(productId) but it's just for a bit of fun, I enjoy the challenge. :) Many thanks!

    Dominic Pettifer Blog: www.dominicpettifer.co.uk

    Database database csharp linq

  • LINQ to SQL in ASP.NET - moving connection string from app.config to web.config
    D Dominic Pettifer

    I'm using LINQ to SQL and putting the generated classes inside a separate assembly (not the website project), but it's all part of the same solution. When the tool generates the classes it places the connection string inside an app.config file in the project, but I'd rather have this connection string inside the web.config file for the website. I've been trying the figure out how to do this and have come across this inside the *.designer.cs file for the LINQ to SQL generated files... public TopicDatabaseDataContext() : base(global::TMS.Library.Properties.Settings.Default.TopicMappingSystemConnectionString, mappingSource) {     OnCreated(); } Now I could replace global::TMS.Library.Properties blah blah with some code to access the connection string in the web.config instead, but since this code is auto generated by a tool, I don't really want to do it this way. Is there a better way?

    Dominic Pettifer Blog: www.dominicpettifer.co.uk

    ASP.NET csharp asp-net database linq tutorial

  • How to get websites port number without HttpContext.Current? [modified]
    D Dominic Pettifer

    Is there a way I can get the websites port number when I don't have access to the current HttpContext object (because it's executing as a background thread, not processing an HTTP request)?

    Dominic Pettifer Blog: www.dominicpettifer.co.uk

    modified on Friday, December 21, 2007 7:09:05 AM

    ASP.NET tutorial question

  • Way to go Microsoft! Finally!
    D Dominic Pettifer

    Maybe I'm missing something, but why don't people simply use the built in WebServer that comes with Visual Studio 2005/2008?

    Dominic Pettifer Blog: www.dominicpettifer.co.uk

    The Lounge visual-studio com windows-admin beta-testing tools

  • Converting HtmlTextWriter to String or Stream
    D Dominic Pettifer

    Are you trying to get the full raw HTML response for the entire page or for just a control?

    Dominic Pettifer Blog: www.dominicpettifer.co.uk

    ASP.NET csharp tutorial question

  • Background Processing/Thread in ASP.NET App, how to keep them running?
    D Dominic Pettifer

    Does anyone have any advice regarding running a background processes or threads in an ASP.NET application. I know it's possible to kick off a background process by responding to Application_Start events in the Global.asax file and using some sort of singleton class. I basically want a task scheduller that kicks off at a certain time without any user intervention and sends emails, or writes to a database etc. The main issue I have is how to keep it running because the ASP.NET AppDomain can get reset or shutdown for a number of reasons, such as when there's no user activity. So my main question is how could I keep it running? I read somewhere someone suggesting getting the background process to do an HttpWebRequest it's own website, thus keeping the AppDomain running, would this work do you think? Also I know about running a Windows Service, but since I'm on shared hosting this isn't an option. Many thanks for your help! :)

    Dominic Pettifer Blog: www.dominicpettifer.co.uk

    ASP.NET help question csharp asp-net database

  • Visual Studio 2008 RTM on MSDN
    D Dominic Pettifer

    In that case could someone post the MSDN link to it. My boss has an MSDN subscription but he can't find it. It is only available to US users, what about UK or Europe?

    Dominic Pettifer Blog: www.dominicpettifer.co.uk

    The Lounge csharp visual-studio

  • Visual Studio 2008 RTM on MSDN
    D Dominic Pettifer

    Could someone post links to where this can be downloaded? Or is it for MSDN subscribers only?

    Dominic Pettifer Blog: www.dominicpettifer.co.uk

    The Lounge csharp visual-studio

  • Prevent Cross-Site Scripting
    D Dominic Pettifer

    Yes. But you ought to process HTML on the way out as it's getting displayed on screen rather than store it in the database in HTML encoded format. This ensures the database stores the data in a platform neutral format, also because some ASP.NET controls perform their own HTML encoding (such as the ToolTip property, or Text property for TextBox controls), and you'll end up encoding the encoding and the user will see < on the screen instead of < Use Server.HtmlEncode(outputString), but don't do this for control properties that already do their own encoding for above reason.

    Dominic Pettifer Blog: www.dominicpettifer.co.uk

    ASP.NET csharp asp-net tools question

  • How to get raw HTML response before it's sent to the client?
    D Dominic Pettifer

    I've Googled this question to death but can't seem to find an answer, but how can I get hold the the raw html response just before it gets sent to the client? The idea being that I want to do something with the final rendered HTML then send it to the client browser, such as compact it, or transform it with an XSLT etc. Can I also do the same thing with css style sheet files and JavaScript files?

    Dominic Pettifer Blog: www.dominicpettifer.co.uk

    ASP.NET question javascript html css xml

  • Stupid PC tricks
    D Dominic Pettifer

    Haven't had time to read all the other posts (at work) so sorry if this has been covered already. I once had one of these free coke can holder joke programs that open up your CD drive. However, rather than just give it to my friend, I went on his computer and placed a shortcut to the program in his 'Startup' folder, and renamed the shortcut to something like 'Epson Print Manager' or something like that (also changed the icon). The result being that his cd drive would open everytime he switched on his PC, and it took him ages to find the cause ;P

    Dominic Pettifer Blog: www.dominicpettifer.co.uk

    The Lounge csharp php wpf com question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups