patterns-and-practices

mobile asp.net techniques

What are your techniques to using mobile with asp.net, I know how to detect mobile but I'm stumped trying to find a good way to show my pages on a mobile device. I'm thinking of just doing a Multi-View and showing the mobile view when they are mobile, however that would not work with our masterpage unless I do same, I'd rather just have...

What are some good practices when writing Javascript/jQuery code?

Possible Duplicates: jQuery Standards and Best Practice Javascript Best Practices After finding that a website I wrote is leaking memory like crazy, I've started trying to improve the way I write my Javascript/jQuery code. For instance, instead of writing: if ($('#elem').is(':checked')) I can write: if ($('#elem')[0].ch...

Making a class available only to a single other class

I have a C# project in which I use the Memento/Command pattern to implement Undo/Redo functionality. The application is a WPF application that uses StructureMap for IOC, has extensive unit tests and makes use of mocking via interfaces using RhinoMocks. In my code I have an Operation class which represents all undoable operations, and I ...

Mocking Enterprise Lib 5 'Database'

Is it possible to mock the enterprise library 5 version of 'Database'? If so... how? There is no IDatabase interface (which is a mystery as I though Microsoft P&P would be more on the ball about testability benefits of exposing such an interface). I have a Repository class which used EntLib 5 Data Access Application Block. I am retro ...

Designing well under deadlines that are too tight

Hello SO; I shall start with some background on myself. I am a junior programmer (almost entirely .Net, unsurprisingly) and have been in my first graduate job for just over a year; before that I took a physics degree and learned programming on the side, first Fortran and then C# off my own bat for a project. After this relatively short...

Preferred method of recoding-resusing batch processes for stability

This is more a system architecture preference/recommendation question: (yeah yeah, it looks like an exam question but i'm just aiming to make myself a better developer) Requirement: You have a raw data source needs to be exported to a proper data store through a batch process (running at regular intervals). Assume you have a reusable p...

What is the difference between these two statements, and why would you choose them?

I'm a beginner at rails. And I've come to understand two different ways to return the same result. What is the difference between these two? And what situation would require you to choose one from the other? Example 1: Object.find(:all).select {|c| c.name == "Foobar" }.size Example 2: Object.count(:conditions => ['name = ?', 'Fooba...

Practices to limit floating point accuracy problems

As programmers, most (if not all of us) know that floating point numbers have a tendency to not be very accurate. I know that this problem can't be avoided entirely, but I am wondering if there are any certain practices, patterns, etc. that can be used to at least reduce floating point errors. Thanks in advance. ...

Best practice for projects and namespaces in framework solution

We are currently setting up our solution which will mostly contain wrapper-classes to consume some public APIs in the first release. Do you have some advice or best practices we can follow to end up with a scalable and clear solution? The current structure looks something like this: imgur ...

best practices for download big files using WCF and ASP.NET

I Have this architecture: WebSite ASP.NET <------> WCF Service <--------> DataBase DAtabase gathering very big files. User request a big file in aspx page, through WCF Service. Service call database, and get the big file. Now, my entity (datacontract) has those fields: string Data1 string Data2 string Data3 byte[] FileBigger How t...

Elegant non-const reference to a QVariantMap node?

Basically I need to generate a nested QVariantMap. (Think JSON): { "foo" : 1, "bar" : { "node" : 0 } } I do this in Qt this way: QVariantMap r, r_bar; r["foo"] = QVariant(1); r_bar["node"] = QVariant(0); r["bar"] = r_bar; Which is very inconvenient for large nested structures. Is there an elegant way of doing this, such as this (...

Select Difference Between Rows (Postgres)

i'm aggregating facebook "like" counts for urls over time. each hour, i check the "like" count and insert it into a timestamped row. how can i get the difference in total between the new row and the previous hour's row? eg, insert total=5 for id=1 at 2pm insert total=12, diff_since_last=7 for id=1 at 3pm thanks! ...

Namespace best practices when dealing with a 3rd party company.

Probably down to preference but I was just after some of your thoughts; I have a scenario where I am working with two 3rd party companies (possibly more in the future) and we provide a service for said companies via individual business logic within the same technology. Would my namespaces be better laid out like this: MyCompany.Technol...

Recommended alternative to abusing UserDetailServiceImpl for non-user-related database lookups?

In the project I am working with, there is a UserDetailServiceImpl class which carries out all of the user-related database lookups. The problem is, I have gotten into the bad habit of doing non-user-related database lookups there too and using the UserDetailServiceImpl class as a default lookup service to avoid doing database lookups ...

Visual studio post build events -- doing them in a project instead of the event dialog

So something I've been doing recently is adding an additional project to my code solutions and doing my post build stuff programmatically in it. This project builds last and then launches itself. cool stuff I can do there is run an ILMerge automation class I created to perform merges automatically if i just give it a project folder, in...

Is it bad practice to use generics as return values from functions?

Somebody told me this but i have not seen this anywhere and i have used it all over, i don't see why would it be bad practice. Example of what i mean is having functions such as: public List<SomeCustomeType> GetListOfStuff() { } or public void DoSomeStuff(List<SomeCustomeType> param) { } can anyone tell me why would this be bad p...

How to mock DataReader to unit test DAL

I have a method in my data access layer that performs mapping. The method accepts a DataReader, and maps the data to the proper domain object properties. Is there a good way to somehow mock the DataReader so I can perform unit tests on the mapping methods without hitting against a physical database? ...

jQuery with ASP.Net UpdatePanel

What is the best way to ensure that events are rebound after an UpdatePanel callback? Suggestions I've seen: function pageLoad(sender, args){ //bind events here. } or use the .live(eventType, handler) method to initially bind the events or var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_endRequest(function() ...

Prevent webservice to be called from different Client App

I have this webservice at work. For that webservice our department have developed a client to consume the webservice. What we want to prevent is, that they develop any other client to consume it. Is there any algorithm, practice that we can improve in our client and webservice communication to validate that the consuming client is our...

How to develop a web application compatible with multiple database management systems

How do you design and manage the development of a web application that should be compatible with multiple database management system such as Oracle and MS SQL Server? If you can't use ORM like NHibernate or EF, how do you maintain database schemas during the development? My approach now is to have a development database on SQL Server...