instruction
stringlengths
0
30k
Let's say you work someplace where every change to source code must be associated with a bug-report or feature-request, and there is no way to get that policy reformed. In such an environment, what is the best way to deal with code refactorings (that is, changes that improve the code but do not fix a bug or add a feature)? - Write up a bug-report and associate the refactoring with it. - Write up a feature-request and associate the refactoring with it. - Sneak in the refactorings while working on code that is associated with a bug-report/feature-request. - Just don't do any refactoring. - Other Note that all bug reports and feature descriptions will be visible to managers and customers.
I don't understand the question -- you're extending System.Exception, and you already added the Elmah field. That's where it belongs -- as a public property of the exception itself.
I often use it for guarding memory usage, things that need to be freed that were returned from the OS. For example: DATA_BLOB blobIn, blobOut; blobIn.pbData=const_cast<BYTE*>(data); blobIn.cbData=length; CryptUnprotectData(&blobIn, NULL, NULL, NULL, NULL, CRYPTPROTECT_UI_FORBIDDEN, &blobOut); Guard guardBlob=guardFn(::LocalFree, blobOut.pbData); // do stuff with blobOut.pbData
for i in `ls $1/resources`; do if [ $i != "database.db" ] && [ $i != "tiles" ] && [ $i != "map.pdf" ] && [ $i != "map.png" ]; then svn export -q $1/resources/$i ../MyProject/Resources/$i
Made this in Java. The regex was borrowed from [this forum][1]. final String regex = "[\\s](\\({0,1}\\d{3}\\){0,1}" + "[- \\.]\\d{3}[- \\.]\\d{4})|" + "(\\+\\d{2}-\\d{2,4}-\\d{3,4}-\\d{3,4})"; final Pattern phonePattern = Pattern.compile(regex); /* The result set */ Set<File> files = new HashSet<File>(); File dir = new File("/initDirPath"); if (!dir.isDirectory()) return; for (File file : dir.listFiles()) { if (file.isDirectory()) continue; BufferedReader reader = new BufferedReader(new FileReader(file)); String line; boolean found = false; while ((line = reader.readLine()) != null && !found) { if (found = phonePattern.matcher(line).find()) { files.add(file); } } } for (File file : files) { System.out.println(file.getAbsolutePath()); } Performed some tests and it went ok! :) Remeber I'm not trying to use the best design here. Just implemented the algorithm for that. [1]: http://forums.msdn.microsoft.com/en-US/regexp/thread/8d4846c0-4eca-427a-b34a-856c7f8695cb/
Unhandled exceptions filter in a windows service
|.net|windows-service|exception|
I am creating a windows service and want to know best practices for this. In all my windows Program I have a form that asks the user if he wants to report the error and if he answers yes I created a case in FogBugz. What should I do in a windows service.
|.net|exception|windows-services|
I have used barcode fonts successfully with SSRS and PDF. You must have the font installed on both the server (for rendering and viewing from the browser), as well as from the client. When using barcode fonts, there's not really a best "match" for postscript so the PDF does not have a valid barcode font embedded with the document, which just yieds a bunch of garbage text. To solve that, just install the font on the client computer that will view the PDF.
You shouldn't fill `.Message` with debug information, but rather with a concise, helpful piece of text. [http://msdn.microsoft.com/en-us/library/system.exception.message.aspx][1] >**The text of Message should completely describe the error and should, when possible, explain how to correct it.** The value of the Message property is included in the information returned by ToString. >The Message property is set only when creating an Exception. If no message was supplied to the constructor for the current instance, the system supplies a default message that is formatted using the current system culture. >[..] >Notes to Inheritors: >The Message property is overridden in classes that require control over message content or format. Application code typically accesses this property when it needs to display information about an exception that has been caught. >The error message should be localized. Response data does not qualify as a description. Not being familiar with elmah, I can't tell you how to extend the `Exception` class while using it. Does elmah implement its own subclass to `Exception`? Or an interface? Can you subclass it yourself? [1]: http://msdn.microsoft.com/en-us/library/system.exception.message.aspx
|python|windows|linux|macos|diskspace|
I need a way to determine the space remaining on a disk volume using python on linux, Windows and OS X. I'm currently parsing the output of the various system calls (df, dir) to accomplish this - is there a better way?
I have spent 4 months on a project working extremely closely with a designer and he has still not picked up the basic idea of CVS (which is not my choice of source control system). I'm talking template files, JavaScript and CSS here. He's not stupid, it's just one of these things that makes his job harder so he resists fully commiting himself to it. In my case I had to really hammer home the point that almost all of my JavaScript depended on the mark-up and when he changed his pure CSS, DIV-based layout into a table-based one without telling me then all my JS is going to break. Often during the course of the project myself and the designer, who I get on with quite well and play soccer with outside of work, had very heated exchanges about our respective responsibilities. If I didn't know him well enough to just get past these exchanges then I think it would have created an unbearable working environment. So I think it's important you establish between you both and with some sort of manager or project supervisor exactly what is expected of both parties during the project. In my case there have been very few problems lately, because the situation with CVS has been sorted out as well as the idea that he can't just go and change the mark-up whenever he feels like it. Rather than try and create template files and work on them directly, the designer only works on static files and its my responsibility to plug them into my template files. It's all about communication and a little bit of compromise on both sides.
How does off-the-shelf software fit in with agile development?
|agile|off-the-shelf-software|
Maybe my understanding of agile development isn't as good as it should be, but I'm curious how an agile developer would potentially use off-the-shelf (OTS) software when the requirements and knowledge of what the final system should be are changing as rapidly as I understand them to (often after each iteration of development). ---------- I see two situations that are of particular interest to me: (1) An OTS system meets the initial set of requirements with little to no modification, other than potential integration into an existing system. However, within a few iterations of development, this system no longer meets the needs without rewriting the core code. The developers must choose to either spend additional time learning the core code behind this OTS software or throw it away and build from scratch. Either would have a drastic impact on development time and project cost. (2) The initial needs are not like any existing OTS system available, however, in the end when the customer accepts the product, it ends up being much like existing solutions due to requirement additions and subtractions. If the developers had more requirements and spent more time working on them up front, this solution could have been used instead of building again. The project was delivered, but later and at a higher cost than necessary. ---------- As a software engineer, part of my responsibilities (as I have been taught), are to deliver high-quality software to the customer on time at the lowest possible cost (among other things). Agile development allows for high-quality software, but in some cases, it might not be apparent that there are better alternatives until it is too late and too much money has been spent. My questions are: 1. How do the agile manager and agile developer deal with these cases? 2. What do the agile paradigms say about these cases?
|refactoring|bug-tracking|
Lets have a look at each option: - Write up a bug-report and associate the refactoring with it. If you feel that, in your opinion, the original code poses a security risk or potential for crashing or instability. Write a small bug report outlining the danger, and then fix it. - Write up a feature-request and associate the refactoring with it. It might be harder to reactor code based on a feature request. But you could use valid feature request to do this which leads me onto the next point... - Sneak in the refactorings while working on code that is associated with a bug-report/feature-request. If there is a valid bug or feature, state that function x had to be change slightly to fix the bug or add the feature. - Just don't do any refactoring. This seems to suggest the self development through improving an application is not allowed. Developers should be allowed, if not, encourage to explorer new techniques and technologies. - Other Perhaps you could discuss your improvement at relevant meeting, giving convincing reasons why the changes should be made. Then at least you will have management backing to the change without having to sneak in the code through another method.
I agree with many and especially [Jason](http://stackoverflow.com/questions/54188/are-c-reads-and-writes-of-an-int-atomic#54224). On windows, one would likely use InterlockedAdd and its friends.
In [Chapter 10. Quantity archetype pattern](http://safari.oreilly.com/032111230X/part03#X2ludGVybmFsX1RvYz94bWxpZD0wMzIxMTEyMzBYL2NoMTA=) of the book [Enterprise Patterns and MDA: Building Better Software with Archetype Patterns and UML](http://www.informit.com/store/product.aspx?isbn=9780321112309&aid=3B419801-6640-4A1F-A653-6CD00295FCDD) by Jim Arlow and Ila Neustadt there is a really useful discussion of this topic and some general patterns you could use as a guide. ![alt text][1] [1]: http://www.businessarchetypes.com/books/enterprise-patterns-and-mda/EnterprisePatternsAndMDAShadow.png
Whatever you do, don't use a static UriBuilder. This introduces all sorts of potential race conditions that you might not detect until you are under heavy load. If two different threads called UriHelper.NormalizeRelativePath at the same time, the return value for one could be passed back to the other caller arbitrarily. If you want to use UriBuilder to do this, just create a new one when you need it (it's not expensive to create).
I usually use [SQLAlchemy][1]. It's pretty powerful and is probably the most mature python ORM. If you're planning on using CherryPy, you might also look into [dejavu][2] as it's by Robert Brewer (the guy that is the current CherryPy project leader). I personally haven't used it, but I do know some people that love it. [SQLObject][3] is a little bit easier to use ORM than SQLAlchemy, but it's not quite as powerful. Personally, I wouldn't use the Django ORM unless I was planning on writing the entire project in Django, but that's just me. [1]: http://www.sqlalchemy.org/ [2]: http://www.aminus.net/dejavu [3]: http://www.sqlobject.org
java.util.Properties is based on Hashtable, which does not store its values in alphabetical order, but in order of the hash of each item, that is why you are seeing the behaviour you are.
We use RNDIS at work. and I've found that it blue screens my machine every now and again (about every month or two). However others (at my work) have not had this happen, so it could just be the particular device that I use. I think it is stable enough for development, so give it a go.
I do it the same way as Gulzar, just keep trying with a loop. In fact I don't even bother with the file system watcher. Polling a network drive for new files once a minute is cheap.
Wow. This is so dependent on the device, connection method, connection type, ISP throttling, etc. involved in the end-to-end link. To try and work out an average speed would be fairly impossible. Think, fat pipe at home (8Gb plus) versus bad wireless connection provided for free at the airport (9.6kb) and you can start to get an idea of the range of connections you're trying to average over. Then we move onto variations in screen sizes and device capabilities. Maybe trawl the UA stings of incoming connectins to get an idea of the capabilities of the user devices being used out there. Maybe see if you can use some sort of geolocation solution to try and see how people are connecting to your site to get an idea of connection capabilities as well. Are you offering the video in a fixed format, i.e. X x Y pixel size? HTH. cheers, Rob
Can't you adjust the RewriteCond to only operate on example.com? RewriteCond %{HTTP:Host} ^example\.com(.*) [NC]
It's not a bad idea. Sometimes I find myself stumbled upon some file trying to figure out where it comes from :) But how are you going to track item's sources? Content can be obtained by various means - web browser, download manager, simply by copying from network share.
We want to keep our package configs in a database table, we know it gets backuped with our other data and we know where to find it. Just a preference. I have found that to get this to work I can use an environment variable configuration to set the connection string of the connection manager that I am reading my package config from. (Although I had to restart the SQL Server agent before it could find the new environment variable. Not ideal when I deploy this to Production) Looks Like when you run an SSIS package as a step in a scheduled task it works in this order: - Load each of the Package Configs in the order they appear in the Package Configuations Organiser - Set the Connection Strings from the Data sources tab in the Job Step properties of the Scheduled Job - Start running package. I would have expected the first 2 to be the other way around so that I can set the data source for my package config from the scheduled job. That is where I would expect other people to look for it when maintaining the package. Cheers Nige
My approach has been to use third party code for some core functionality. For example, I use Subsonic for my data access, Devexpress components for UI and Peter Blum Data Entry Suite for data entry and validation. Subsonic is open source, Devexpress Peter Blum's controls have source code available for an extra fee. It would be impossible for me to get the functionality of these control if I tried to write them myself. This approach allows me to focus on the custom functionality of my application without having to worry about how I will access the database or how I make an editable treelist that looks pretty. Sure I don't have a fully configured and working forum but I know that I'll be using a SQL database for my app and I won't have to try and get different data storage components to work together. I don't have a wiki but I know how to use the devexpress ui components and formatting and validating data entry is breeze with Peter Blum's controls. In other words, learn tools (and of course choose them carefully) that will speed development of all of your projects then you can focus on portions of your application that have to be customized. I'm not too concerned if it's open source or not as long as source code is available. If it's open source I donate to the project. If it's a commercial component I will pay a fair price. In any case, the tools help to make programming fun and the results have data integrity and are great looking. If I develop a wiki or forum I know that I can get them to work together seamlesslessly. Finally, all of the tools I have mentioned have been around for a long time and are written by outstanding developers with great reputations.
Maybe my understanding of agile development isn't as good as it should be, but I'm curious how an agile developer would potentially use off-the-shelf (OTS) software when the requirements and knowledge of what the final system should be are changing as rapidly as I understand them to (often after each iteration of development). ---------- I see two situations that are of particular interest to me: (1) An OTS system meets the initial set of requirements with little to no modification, other than potential integration into an existing system. However, within a few iterations of development, this system no longer meets the needs without rewriting the core code. The developers must choose to either spend additional time learning the core code behind this OTS software or throw it away and build from scratch. Either would have a drastic impact on development time and project cost. (2) The initial needs are not like any existing OTS system available, however, in the end when the customer accepts the product, it ends up being much like existing solutions due to requirement additions and subtractions. If the developers had more requirements and spent more time working on them up front, this solution could have been used instead of building again. The project was delivered, but later and at a higher cost than necessary. ---------- As a software engineer, part of my responsibilities (as I have been taught), are to deliver high-quality software to the customer on time at the lowest possible cost (among other things). Agile development allows for high-quality software, but in some cases, it might not be apparent that there are better alternatives until it is too late and too much money has been spent. My questions are: 1. How does off-the-shelf software fit in with agile development? 2. How do the agile manager and agile developer deal with these cases? 3. What do the agile paradigms say about these cases?
Depends on what you want for performance. The case statement is ugly but does not consume memory that would need to be allocated. However, you could create a class for your fields and load instances of them into a Dictionary. Perform this operation in the global.asp script so it only happens once. Store the dictionary in the global asp collection such that it is only allocated once but used with each page call. My appologies for not getting too specific here... it's been a while.
Is there anything wrong with o.getClass().equals(T.class) if accepting subclasses is ok you can use something like o instanceof T.class
Is there anything wrong with o.getClass().equals(T.class) if accepting subclasses is ok you can use something like o instanceof T.class To answer myself: yes there is. I could only make it working like this: public class Test<E> { private E e; public void setE(E e) { this.e = e; } public boolean sameClassAs(Object o) { return (o.getClass().equals(e.getClass())); } public boolean sameClassAs2(Object o) { return e.getClass().isInstance(o); } }
I could only make it working like this: public class Test<E> { private E e; public void setE(E e) { this.e = e; } public boolean sameClassAs(Object o) { return (o.getClass().equals(e.getClass())); } public boolean sameClassAs2(Object o) { return e.getClass().isInstance(o); } }
To draw a centered text: TextRenderer.DrawText(g, "my text", Font, Bounds, ForeColor, BackColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.GlyphOverhangPadding); Determining optimal font size to fill an area is a bit more difficult -- the only solution I found is to repeatedly measure the string until I find one that fits. Something like: Font FindBestFitFont(Graphics g, String text, Font font, Size proposedSize, TextFormatFlags flags) { // Compute actual size, shrink if needed while (true) { Size size = TextRenderer.MeasureText(g, Text, _font, proposedSize, flags); // It fits, back out if ( size.Height <= proposedSize.Height && size.Width <= proposedSize.Width) { return font; } // Try a smaller font (90% of old size) Font oldFont = font; font = new Font(font.FontFamily, (float)(font.Size * .9)); oldFont.Dispose(); } You'd use this as: Font bestFitFont = FindBestFitFont(g, text, someBigFont, sizeToFitIn, flags); // Then do your drawing as above // Don't forget to dispose your font (if needed)...
To draw a centered text: TextRenderer.DrawText(g, "my text", Font, Bounds, ForeColor, BackColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.GlyphOverhangPadding); Determining optimal font size to fill an area is a bit more difficult -- the only solution I found is to repeatedly measure the string until I find one that fits. Something like: Font FindBestFitFont(Graphics g, String text, Font font, Size proposedSize, TextFormatFlags flags) { // Compute actual size, shrink if needed while (true) { Size size = TextRenderer.MeasureText(g, text, font, proposedSize, flags); // It fits, back out if ( size.Height <= proposedSize.Height && size.Width <= proposedSize.Width) { return font; } // Try a smaller font (90% of old size) Font oldFont = font; font = new Font(font.FontFamily, (float)(font.Size * .9)); oldFont.Dispose(); } } You'd use this as: Font bestFitFont = FindBestFitFont(g, text, someBigFont, sizeToFitIn, flags); // Then do your drawing using the bestFitFont // Don't forget to dispose the font (if/when needed)
To draw a centered text: TextRenderer.DrawText(g, "my text", Font, Bounds, ForeColor, BackColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.GlyphOverhangPadding); Determining optimal font size to fill an area is a bit more difficult. One working soultion I found is trial-and-error: start with a big font, then repeatedly measure the string and shrink the font until it fits. Font FindBestFitFont(Graphics g, String text, Font font, Size proposedSize, TextFormatFlags flags) { // Compute actual size, shrink if needed while (true) { Size size = TextRenderer.MeasureText(g, text, font, proposedSize, flags); // It fits, back out if ( size.Height <= proposedSize.Height && size.Width <= proposedSize.Width) { return font; } // Try a smaller font (90% of old size) Font oldFont = font; font = new Font(font.FontFamily, (float)(font.Size * .9)); oldFont.Dispose(); } } You'd use this as: Font bestFitFont = FindBestFitFont(g, text, someBigFont, sizeToFitIn, flags); // Then do your drawing using the bestFitFont // Don't forget to dispose the font (if/when needed)
I used the following code is an example of how I captured SOAP requests in a application written a while back. <System.Diagnostics.Conditional("DEBUG")> _ Private Sub CheckHTTPRequest(ByVal functionName As String) Dim e As New UTF8Encoding() Dim bytes As Long = Me.Context.Request.InputStream.Length Dim stream(bytes) As Byte Me.Context.Request.InputStream.Seek(0, IO.SeekOrigin.Begin) Me.Context.Request.InputStream.Read(stream, 0, CInt(bytes)) Dim thishttpRequest As String = e.GetString(stream) My.Computer.FileSystem.WriteAllText("D:\SoapRequests\" & functionName & ".xml", thishttpRequest, False) End Sub Setting the conditional attribute like I did makes the compiler ignore the method call for all build types other than debug. Sorry for the VB, it is forced upon me.
java.util.Properties is a subclass of java.util.**Hashtable**. ('Hash', being the key here.)You'd have to come up with your own customer implementation based on something that keeps/defines order...like a TreeMap.
From a physical and logical architecture standpoint, nothing beats the whiteboard, drawing up the layers/tiers of the application in boxes. Then create an electronic copy using Visio. After that, iteratively dive into each layer and design it using appropriate tools and techniques. Here are what I commonly use: 1. Database: ERD 2. Business Objects (and Service Contracts): UML class diagrams 3. UI: prototypes & wireframes 4. Workflows and asynchronous operations: flowcharts and sequence diagrams
If you find that the time needed to fully implement OO in your project is needlessly causing missed deadlines, then yes. There has to be a trade off between releasing software and full OO fidelity. How to decide depends on the person, the team, the project and the organization running the project.
Yes, of course there is :-) object oriented techniques are a tool ... if you use the wrong tool for a given job, you will be over complicating things (think spoon when all you need is a knife). To me, I judge "how much" by the size and scope of the project. If it is a small project, sometimes it does add too much complexity. If the project is large, you will still be taking on this complexity, but it will pay for itself in ease of maintainability, extensibility, etc.
Glade is very useful for creating interfaces, it means you can easily change the GUI without doing much coding. You'll find that if you want to do anything useful (e.g. build a treeview) you will have to get familiar with various parts of the GTK documentation - in practice finding a good tutorial/examples.
Yes, it's definitely possible -- common, either. I once worked with a guy who created a data structure to bind to a dropdown list -- so he could allow users to select a gender. True, that would be useful if the list of possible genders were to change, but they haven't as yet (we don't live in California)
My advice is not to overthink it. That usually results in over or under doing SOMETHING (if not OO). The rule of thumb that I usually use is this: if it makes the problem easier to wrap my head around, I use an object. If another paradigm makes it easier to wrap my head around than it would be if I used an object, I use that. That strategy has yet to fail me.
Even shorter: for i in `ls $1/resources`; do if [ $i != databse.db -a $i != titles -a $i != map.pdf ]; then svn export -q $1/resources/$i ../MyProject/Resources/$i fi done; The `-a` in the if expression is the equivalent of the boolean AND in shell-tests. For more see `man test`
JBoss wraps up all DataSources with it's own ones. That lets it play tricks with autocommit to get the specified J2EE behaviour out of a JDBC connection. They are _mostly_ serailizable. But you needn't trust them. I'd look carefully at it's wrappers. I've written a surrogate for JBoss's J2EE wrappers wrapper for JDBC that works with OOCJNDI to get my DAO code unit test-able standalone. <example code would go here.. but you know...> You just wrap java.sql.Driver, point OOCJNDI at your class, and run in JUnit. The Driver wrapper can just directly create a SQL Driver and delegate to it. Return a java.sql.Connection wrapper of your own devising on Connect. A ConnectionWrapper can just wrap the Connection your Oracle driver gives you, and all it does special is set Autocommit true. Don't forget Eclipse can wrt delgates for you. Add a member you need to delegate to , then select it and right click, source -=>add delgage methods. This is great when you get paid by the line ;-) Bada-bing, Bada-boom, JUnit out of the box J2EE testing. Your problem is probably amenable to the same thing, with JUnit crossed out and FatCLient written in an crayon. My FatClient uses RMI generated with xdoclet to talk to the J2EE server, so I don't have your problem.
I have discovered another caveat (which in my case was what was "wrong") It appears that the unit with the HelpInsight comments **must** be explicitly added to the project. It is not sufficient to simply have the unit in a path that is searched when compiling the project. In other words, the unit must be included in the Project's .dpr / .dproj file. (Using the Project | "Add to Project" menu option)
Not a direct answer to your question, which Jonas has answered well, however this may be of assistance if you are worried about equality testing in hashes From our tests, depending on what you are requiring with hashcodes, in C#, hashcodes do not need to be unique for Equality operations. As an example, consider the following: We had a requirement to overload the equals operator, and therefore the GetHashCode function of our objects as they had become volatile and stateless, and sourcing themselves directly from data, so in one place of the application we needed to ensure that an object would be viewed as equal to another object *if it was sourced from the same data*, not just if it was the same reference. Our unique data identifiers are Guids. The equals operator was easy to cater for as we just checked on the Guid of the record (after checking for null. Unfortuantely the HashCode data size depends on the operating system, and on our 32 bit system, the hashcode would be 32 bit. Mathematically, when we override the GetHashCode function, it is impossible to generate a hashcode from a guid which is greater than 32 bit (look at it from the converse, how would you translate a 32 bit integer into a guid?). We then did some tests where we took the Guid as a string and returned the HashCode of the Guid, which almost always returns a unique identifier in our tests, but not always. What we did notice however, when an object is in a hashed collection object (a hashtable, a dictionary etc), when 2 objects are not unique but their hashcodes are, the hashcode is only used as a first option lookup, if there are non-unique hash codes being used, *the equality operator is always used as a fall back to detirmine equality*. As I said this may or may not be relevant to your situation, but if it is it's a handy tip.
Not a strict answer per se, but I think that using off the shelf software as a component in a software solution can be very beneficial if: - It's data is open, e.g. an open database or a web service to interact with it - The off the shelf system can customised *easily* using a similar programming paradigm to the rest of your solution - It can be seamlessly adapted to the rest of your work-flow I'm a big fan of not re-inventing the wheel, and using your development skills to design the 'glue' between off-the-shelf solutions can be a big win. Remember 'open' is the important part, and a vendor will often tout their solution as open when it isn't really.
Be aware that [Microsoft do not recommend that you static link the runtime into your project][1], as this prevents it from being serviced by windows update to fix critical security bugs. There are also potential problems if you are passing memory between your main .exe and .dll files as if each of these static links the runtime you can end up with malloc/free mismatch problems. You can include the DLLs with the executable, without compiling them into the .exe and without running the redist tool - this is what I do and it seems to work fine. The only fly in the ointment is that you need to include the files twice if you're distributing for a wide range of Windows versions - newer OSs need the files in manifest-defined directories, and older ones want all the files in the program directory. [1]: http://blogs.msdn.com/martynl/archive/2005/10/13/480880.aspx
Although generally a UML tool, I would look at [StarUML][1]. It supports [additional modules beyond what are already built in][2]. If it doesn't have what you need built in or as a module, I supposed you could make your own, but I don't know how difficult that is. [1]: http://staruml.sourceforge.net/en/ [2]: http://staruml.sourceforge.net/en/modules.php
I don't think that your results are all that surprising -- if anything it is that Postgres is so fast. Does the Postgres query run faster a second time once it has had a chance to cache the data? To be a little fairer your test for Java and Python should cover the cost of acquiring the data in the first place (ideally loading it off disk). If this performance level is a problem for your application in practice but you need a RDBMS for other reasons then you could look at [memcached][1]. You would then have faster cached access to raw data and could do the calculations in code. [1]: http://www.danga.com/memcached/
Quite frankly you should tell the designer that images can, should and "will be put in source control mister!" :) It may be slightly non-conventional and you wont be able to do a merge or anything of that nature, but there will be revisions and a history, etc .. Images can also be embedded in a resource file which goes into source control as well. XAML can (and should) be put in source control and as its a markup file it will benefit from all of the features. As far as tips from working with a designer, the one you are working with scares the heck outta me just by that comment alone, so it may all boil down to WHO you are working with. I would explain basic best practices in a nice manner and proceed from there.
using System.IO; DriveInfo[] allDrives = DriveInfo.GetDrives(); foreach (DriveInfo d in allDrives) { if (d.IsReady && d.DriveType == DriveType.Removable) { // This is the drive you want... } } The DriveInfo class documentation is here: http://msdn.microsoft.com/en-us/library/system.io.driveinfo.aspx
.NET Interfaces
|.net|user-controls|interface|
Over the past few years I've changed from having a long flowing page of controls that I hid/showed to using a lot of user controls. I've always had a bit of a discussion between co-workers on best practices. Should you have properties that you populate, or use paramterized sub's to load the information in your controls? Part of my fear of using paramteter's is the fact that I cannot make sure that everything will be populated. What is the basic rule's for using interfaces? I've never created one. And should I try this, or stay with a "sub load"?
@jj33, you're absolutely right, on both counts. #include <stdio.h> int main(int argc, char *argv[]) { char *s = "Hello, World"; char *s2 = "he"; printf("4s: '%4s'\n", s); printf(".4s: '%.4s'\n", s); printf("4s2: '%4s'\n", s2); printf(".4s2: '%.4s'\n", s2); return 0; } $ gcc -o foo foo.c $ ./foo 4s: 'Hello, World' .4s: 'Hell' 4s2: ' he' .4s2: 'he' Good catch!
If you understand the process of retain/release then there are two golden rules that are "duh" obvious to established Cocoa programmers, but unfortunately are rarely spelled out this clearly for newcomers. **1) If a function which returns an object has 'alloc', 'create' or 'copy' in its name then the object is yours. You must call [object release] when you are finished with it. Or CFRelease(object) if it's a Core-Foundation object. 2) If it does NOT have one of these words in its name then the object belongs to someone else. You must call [object retain] if you wish to keep the object after the end of your function.** You would be well served to also follow this convention in functions you create yourself. (Nitpickers: Yes, there are unfortunately a few API calls that are exceptions to these rules but they are rare).
To echo what Lance said - the SubSonic query language has a fluent interface which isn't as pretty as LINQ, but gives you some of the benefits (compile time checking, intellisense, etc.).
I'm not sure if interfaces are going to help you a lot here. My understanding is that you are breaking a page down into set of "composite" user controls that contain other controls, and you want to decide whether to use properties for setting values. I guess this really depends on how the user controls are designed and whether they are being dynamically added to a page etc (one possible scenario). I have a personal preference for specifying stuff in a constructor or using a factory method to create controls. I assume responsibility at creation for making sure that everything is set. My experience with properties is that I'll sometimes forget to set something and not realize my mistake. Your point about setting properties or using a sub, and everything being populated doesn't make a lot of sense to me. If you have some sort of dependency and need something else to be loaded then this could happen irrespective of whether it's a property or sub. I would refer to any book on VB.NET/C#/OOP to see the syntax for interfaces. Interfaces basically describe a contract for a class. If you have class A and B and both implement an interface called ITime then both will provide all of the methods defined on ITime. They can still add their own methods but they must at minimum include an implementation of ITime's methods (eg. we might have GetDate(), GetCurrentTime() as methods on ITime). An interface doesn't tell class A or B how those methods should work - just their name, parameters and return type. Lookup inheritance in an OOP book for more information on how interfaces inheritance is different from implementation inheritance.
Also keep in mind the **[SC.exe util][1]** which does not require visual studio to be installed. You can simply copy this exe to the server you want to create the service or even **run it remotely**. Use the **obj** parameter to specify a user. Apparently there is a GUI for this tool, but I have not used it. [1]: http://support.microsoft.com/?kbid=251192
I guess it is possible, but its hard to answer your in abstract terms (no pun intended). Give an example of over OO.
What the certificate validation is doing is validating all certificates in the chain. In order to truely do that it just contact the root store of each of those cerficates. If that's not something you want to happen you can deploy your own root store locally.
This one isnt really a book for the beginning programmer, but if you're looking for SOA design books, then [SOA in Practice: The Art of Distributed System Design][1] is for you. ![alt text][2] [1]: http://www.amazon.com/SOA-Practice-Distributed-System-Design/dp/0596529554/ref=pd_bbs_sr_3?ie=UTF8&s=books&qid=1221059090&sr=1-3 [2]: http://ecx.images-amazon.com/images/I/51Rk12gIKiL._SL500_AA240_.jpg
Yes. See the concept of the "[golden hammer][1] [antipattern][2]" [1]: http://en.wikipedia.org/wiki/Golden_hammer [2]: http://sourcemaking.com/antipatterns/golden-hammer
Even if you are familiar with the internals, you should still load test your assumptions. I like to use the [PEAR Benchmark][1] package to compare different code. If you can isolate your code, you can keep your load testing simple. A typical technique is to run each option some number of times and see which one is faster. For example, if you have a class, you can write a test case and that puts it through it's paces and run it several times. [1]: http://pear.php.net/package/Benchmark
If you're working on a block of code, in most cases that's because there's either a bug fix or new feature that requires that block of code to change, and the refactoring is either prior to the change in order to make it easier, or after the change to tidy up the result. In either case, you can associate the refactoring with that bug fix or feature.
Is this a webapp? Place your SoapExtension code in a HTTPModule, and inject the SOAP envelope into the HTTPOutput stream. That way, when in debug mode, I picture something like a collapsible div on the top of the page that lists all SOAP communication for that page.
I've found it easier to pool and reuse XMLHTTPRequest objects instead of creating new ones...
I think there are times when OO design can be taken to an extreme and even in very large projects make the code less readable and maintainable. For instance, there can be use in a footware base class, and child classes of sneaker, dress shoe, etc. But I have read/reviewed people's code where it seemed as though they were going to the extreme of creating classes beneath that for NikeSneakers and ReebokSneakers. Certainly there are differences between the two, but to have readable, maintainable code, I believe its important, at times, to expand a class to adapt to differences rather than creating new child classes to handle the differences.
Not a direct answer to your question, which Jonas has answered well, however this may be of assistance if you are worried about equality testing in hashes From our tests, depending on what you are requiring with hashcodes, in C#, hashcodes do not need to be unique for Equality operations. As an example, consider the following: We had a requirement to overload the equals operator, and therefore the GetHashCode function of our objects as they had become volatile and stateless, and sourcing themselves directly from data, so in one place of the application we needed to ensure that an object would be viewed as equal to another object *if it was sourced from the same data*, not just if it was the same reference. Our unique data identifiers are Guids. The equals operator was easy to cater for as we just checked on the Guid of the record (after checking for null). Unfortuantely the HashCode data size (being an int) depends on the operating system, and on our 32 bit system, the hashcode would be 32 bit. Mathematically, when we override the GetHashCode function, it is impossible to generate a unique hashcode from a guid which is greater than 32 bit (look at it from the converse, how would you translate a 32 bit integer into a guid?). We then did some tests where we took the Guid as a string and returned the HashCode of the Guid, which almost always returns a unique identifier in our tests, but not always. What we did notice however, when an object is in a hashed collection object (a hashtable, a dictionary etc), when 2 objects are not unique but their hashcodes are, the hashcode is only used as a first option lookup, if there are non-unique hash codes being used, *the equality operator is always used as a fall back to detirmine equality*. As I said this may or may not be relevant to your situation, but if it is it's a handy tip.
Not a direct answer to your question, which Jonas has answered well, however this may be of assistance if you are worried about equality testing in hashes From our tests, depending on what you are requiring with hashcodes, in C#, hashcodes do not need to be unique for Equality operations. As an example, consider the following: We had a requirement to overload the equals operator, and therefore the GetHashCode function of our objects as they had become volatile and stateless, and sourcing themselves directly from data, so in one place of the application we needed to ensure that an object would be viewed as equal to another object *if it was sourced from the same data*, not just if it was the same reference. Our unique data identifiers are Guids. The equals operator was easy to cater for as we just checked on the Guid of the record (after checking for null). Unfortuantely the HashCode data size (being an int) depends on the operating system, and on our 32 bit system, the hashcode would be 32 bit. Mathematically, when we override the GetHashCode function, it is impossible to generate a unique hashcode from a guid which is greater than 32 bit (look at it from the converse, how would you translate a 32 bit integer into a guid?). We then did some tests where we took the Guid as a string and returned the HashCode of the Guid, which almost always returns a unique identifier in our tests, but not always. What we did notice however, when an object is in a hashed collection object (a hashtable, a dictionary etc), when 2 objects are not unique but their hashcodes are, the hashcode is only used as a first option lookup, if there are non-unique hash codes being used, *the equality operator is always used as a fall back to detirmine equality*. As I said this may or may not be relevant to your situation, but if it is it's a handy tip. **UPDATE** To demonstrate, we have a Hashtable: Key:Object A (Hashcode 1), value Object A1 Key:Object B (Hashcode 1), value Object B1 Key:Object C (Hashcode 1), value Object C1 Key:Object D (Hashcode 2), value Object D1 Key:Object E (Hashcode 3), value Object E1 When I call the hashtable for the object with the key of Object A, the object A1 will be returned after 2 steps, a call for hashcode 1, then an equality check on the key object as there is not a unique key with the hashcode 1 When I call the hashtable for the object with the key of Object D, the object D1 will be returned after 1 step, a hash lookup
I think I read somewhere that if during an iteration you discover that you have more than 20% more work that you initially thought then you should abandon the sprint and start planning a new one taking into account the additional work. So this would mean replanning with the business to see if they still want to go ahead with the original requirements now that you know more. At our company we also make use of prototyping before the sprint to try and identify these kind of situations before they arise on a sprint. Although of course that still may not identify the kind of situation that you describe.
I Don't know of any cross-platform way to achieve this, but maybe a good workaround for you would be to write a wrapper class that checks the operating system and uses the best method for each. For Windows, there's the [GetDiskFreeSpaceEx][1] method in the win32 extensions. [1]: http://aspn.activestate.com/ASPN/docs/ActivePython/2.2/PyWin32/win32api__GetDiskFreeSpaceEx_meth.html
in c# you can get the same by using the System.IO.DriveInfo class using System.IO; public static class GetDrives { public static IEnumerable<DriveInfo> GetCDDVDAndRemovableDevices() { return DriveInfo.GetDrives(). Where(d => d.DriveType == DriveType.Removable && d.DriveType == DriveType.CDRom); } }
there is a Number.localeFormat function but I'm not sure it's what your after [http://msdn.microsoft.com/en-gb/library/bb310813.aspx][1] [1]: http://msdn.microsoft.com/en-gb/library/bb310813.aspx
The [os.statvfs()](http://python.org/doc/2.5/lib/os-file-dir.html) function is a better way to get that information for Unix-like platforms (including OS X). The Python documentation says "Availability: Unix" but it's worth checking whether it works on Windows too in your build of Python (ie. the docs might not be up to date).
The [os.statvfs()](http://python.org/doc/2.5/lib/os-file-dir.html) function is a better way to get that information for Unix-like platforms (including OS X). The Python documentation says "Availability: Unix" but it's worth checking whether it works on Windows too in your build of Python (ie. the docs might not be up to date). Otherwise, you can use the [pywin32](http://sourceforge.net/projects/pywin32/) library to directly call the [GetDiskFreeSpaceEx][1] function. [1]: http://msdn.microsoft.com/en-us/library/aa364937(VS.85).aspx
In Oracle you can also use the EXISTS statement, which in some cases is faster. For example... SELECT name, number FROM cust WHERE cust IN ( SELECT cust_id FROM big_table ) AND entered > SYSDATE -1 would be slow. but SELECT name, number FROM cust **c** WHERE EXISTS ( SELECT cust_id FROM big_table **WHERE cust_id=c.cust_id** ) AND entered > SYSDATE -1 would be very fast with proper indexing. You can also use this with multiple parameters.
one way you could do it is to declare an interface say IGisObject that has the common properties declared on the interface. Then implement a concrete class which maps to each table. That way they'll still be all of type IGisObject.
Average User Download Speeds
|internet|download|performance|average|
Any ideas what the average user's download speed is? I'm working on a site that streams video and am trying to figure out what an average download speed as to determine quality. I know i might be comparing apples with oranges but I'm just looking for something to get a basis for where to start.
|internet|download|performance|average|
|internet|download|performance|average|
Looking for ASP.NET code to render a form that displays a view of an object
|asp.net|propertygrid|control|
I've got the task of displaying a web form to represent the properties in a .NET class. In WinForms, there's a pre-fab control named PropertyGrid that is a lot like what I need. I'm just looking for something to display a simple layout of property names next to an appropriate control like a textbox or a dropdownlist for enum properties. Does anything like this already exist for ASP.NET, or will I be rolling my own here? thanks!
|asp.net|control|propertygrid|
I've got the task of displaying a web form to represent the properties in a .NET class. In WinForms, there's a pre-fab control named PropertyGrid that is a lot like what I need. I'm just looking for something to display a simple layout of property names next to an appropriate control like a textbox for strings or a dropdownlist for enum properties. Does anything like this already exist for ASP.NET, or will I be rolling my own here? thanks!
|asp.net|controls|propertygrid|
How should I monitor potential threats to my site?
|monitor|alert|
By looking at our DB's error log, we found that there was a constant stream of almost successful SQL injection attacks. Some quick coding avoided that, but how could I have setup a monitor for both the DB and Web server (including POST requests) to check for this? By this I mean if there are off the shelf tools for script-kiddies, are there off the shelf tools that will alert you to their sudden random interest in your site?
|monitor|alert|
How to provide namespaces in JavaScript with instanced objects