Daily Archives

Articles indexed Friday May 28 2010

Page 7/107 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Resizing a container when child's visibility is changed?

    - by deux11
    When I set the visible property to false for a child in a container, how can I get the container to resize? In the example bellow, when clicking on "Toggle", "containerB" is hidden, but the main container's scrollable area is not resized. (I do not want to scroll through a lot of empty space.) <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> <![CDATA[ public function toggle():void { containerB.visible = !containerB.visible; } ]]> </mx:Script> <mx:VBox height="300" width="200" horizontalAlign="center"> <mx:Button label="Toggle" click="toggle()" width="200"/> <mx:VBox id="containerA" height="400" width="150" horizontalAlign="center"> <mx:Button label="A" height="400" width="100"/> </mx:VBox> <mx:VBox id="containerB" height="400" width="150" horizontalAlign="center"> <mx:Button label="B" height="400" width="100"/> </mx:VBox> </mx:VBox>

    Read the article

  • Recommend me an architecture for this Facebook application

    - by andybaird
    Firstly, this question is subjective. There is not a right answer for this question and it really depends on what works for you. I'm hoping to use this thread as a breeding ground for ideas. I hope this is acceptable in this medium. I'm working on building a Facebook app that will be replacing an already popular app that gets ~50k hits a day. The original app is using a very typical LAMP setup with help from some Zend libraries for database layer extraction. For the most part the app worked well, except to solve a lot of issues I ended up fragmenting tables to speed things up. As a result, I couldn't do a lot of things with the app that I wanted to (namely any processing using aggregate data that needed to be returned quickly) So I'm starting to design plans for the next version of this application, and I have a whole bunch of new and cool features that I know would choke my current setup. I'm looking for technological recommendations of data storage methods that scale well. The database does not necessarily need to be relational, simple key/value storage would suffice (although at present time I know little to nothing about KV stores) What's your recommendation? How would you tackle this? I'd like to take a completely free approach to this -- although I am most familiar and comfortable using PHP, I want to leave all technical options open.

    Read the article

  • Code Reuse is (Damn) Hard

    - by James Michael Hare
    Being a development team lead, the task of interviewing new candidates was part of my job.  Like any typical interview, we started with some easy questions to get them warmed up and help calm their nerves before hitting the hard stuff. One of those easier questions was almost always: “Name some benefits of object-oriented development.”  Nearly every time, the candidate would chime in with a plethora of canned answers which typically included: “it helps ease code reuse.”  Of course, this is a gross oversimplification.  Tools only ease reuse, its developers that ultimately can cause code to be reusable or not, regardless of the language or methodology. But it did get me thinking…  we always used to say that as part of our mantra as to why Object-Oriented Programming was so great.  With polymorphism, inheritance, encapsulation, etc. we in essence set up the concepts to help facilitate reuse as much as possible.  And yes, as a developer now of many years, I unquestionably held that belief for ages before it really struck me how my views on reuse have jaded over the years.  In fact, in many ways Agile rightly eschews reuse as taking a backseat to developing what's needed for the here and now.  It used to be I was in complete opposition to that view, but more and more I've come to see the logic in it.  Too many times I've seen developers (myself included) get lost in design paralysis trying to come up with the perfect abstraction that would stand all time.  Nearly without fail, all of these pieces of code become obsolete in a matter of months or years. It’s not that I don’t like reuse – it’s just that reuse is hard.  In fact, reuse is DAMN hard.  Many times it is just a distraction that eats up architect and developer time, and worse yet can be counter-productive and force wrong decisions.  Now don’t get me wrong, I love the idea of reusable code when it makes sense.  These are in the few cases where you are designing something that is inherently reusable.  The problem is, most business-class code is inherently unfit for reuse! Furthermore, the code that is reusable will often fail to be reused if you don’t have the proper framework in place for effective reuse that includes standardized versioning, building, releasing, and documenting the components.  That should always be standard across the board when promoting reusable code.  All of this is hard, and it should only be done when you have code that is truly reusable or you will be exerting a large amount of development effort for very little bang for your buck. But my goal here is not to get into how to reuse (that is a topic unto itself) but what should be reused.  First, let’s look at an extension method.  There’s many times where I want to kick off a thread to handle a task, then when I want to reign that thread in of course I want to do a Join on it.  But what if I only want to wait a limited amount of time and then Abort?  Well, I could of course write that logic out by hand each time, but it seemed like a great extension method: 1: public static class ThreadExtensions 2: { 3: public static bool JoinOrAbort(this Thread thread, TimeSpan timeToWait) 4: { 5: bool isJoined = false; 6:  7: if (thread != null) 8: { 9: isJoined = thread.Join(timeToWait); 10:  11: if (!isJoined) 12: { 13: thread.Abort(); 14: } 15: } 16: return isJoined; 17: } 18: } 19:  When I look at this code, I can immediately see things that jump out at me as reasons why this code is very reusable.  Some of them are standard OO principles, and some are kind-of home grown litmus tests: Single Responsibility Principle (SRP) – The only reason this extension method need change is if the Thread class itself changes (one responsibility). Stable Dependencies Principle (SDP) – This method only depends on classes that are more stable than it is (System.Threading.Thread), and in itself is very stable, hence other classes may safely depend on it. It is also not dependent on any business domain, and thus isn't subject to changes as the business itself changes. Open-Closed Principle (OCP) – This class is inherently closed to change. Small and Stable Problem Domain – This method only cares about System.Threading.Thread. All-or-None Usage – A user of a reusable class should want the functionality of that class, not parts of that functionality.  That’s not to say they most use every method, but they shouldn’t be using a method just to get half of its result. Cost of Reuse vs. Cost to Recreate – since this class is highly stable and minimally complex, we can offer it up for reuse very cheaply by promoting it as “ready-to-go” and already unit tested (important!) and available through a standard release cycle (very important!). Okay, all seems good there, now lets look at an entity and DAO.  I don’t know about you all, but there have been times I’ve been in organizations that get the grand idea that all DAOs and entities should be standardized and shared.  While this may work for small or static organizations, it’s near ludicrous for anything large or volatile. 1: namespace Shared.Entities 2: { 3: public class Account 4: { 5: public int Id { get; set; } 6:  7: public string Name { get; set; } 8:  9: public Address HomeAddress { get; set; } 10:  11: public int Age { get; set;} 12:  13: public DateTime LastUsed { get; set; } 14:  15: // etc, etc, etc... 16: } 17: } 18:  19: ... 20:  21: namespace Shared.DataAccess 22: { 23: public class AccountDao 24: { 25: public Account FindAccount(int id) 26: { 27: // dao logic to query and return account 28: } 29:  30: ... 31:  32: } 33: } Now to be fair, I’m not saying there doesn’t exist an organization where some entites may be extremely static and unchanging.  But at best such entities and DAOs will be problematic cases of reuse.  Let’s examine those same tests: Single Responsibility Principle (SRP) – The reasons to change for these classes will be strongly dependent on what the definition of the account is which can change over time and may have multiple influences depending on the number of systems an account can cover. Stable Dependencies Principle (SDP) – This method depends on the data model beneath itself which also is largely dependent on the business definition of an account which can be very inherently unstable. Open-Closed Principle (OCP) – This class is not really closed for modification.  Every time the account definition may change, you’d need to modify this class. Small and Stable Problem Domain – The definition of an account is inherently unstable and in fact may be very large.  What if you are designing a system that aggregates account information from several sources? All-or-None Usage – What if your view of the account encompasses data from 3 different sources but you only care about one of those sources or one piece of data?  Should you have to take the hit of looking up all the other data?  On the other hand, should you have ten different methods returning portions of data in chunks people tend to ask for?  Neither is really a great solution. Cost of Reuse vs. Cost to Recreate – DAOs are really trivial to rewrite, and unless your definition of an account is EXTREMELY stable, the cost to promote, support, and release a reusable account entity and DAO are usually far higher than the cost to recreate as needed. It’s no accident that my case for reuse was a utility class and my case for non-reuse was an entity/DAO.  In general, the smaller and more stable an abstraction is, the higher its level of reuse.  When I became the lead of the Shared Components Committee at my workplace, one of the original goals we looked at satisfying was to find (or create), version, release, and promote a shared library of common utility classes, frameworks, and data access objects.  Now, of course, many of you will point to nHibernate and Entity for the latter, but we were looking at larger, macro collections of data that span multiple data sources of varying types (databases, web services, etc). As we got deeper and deeper in the details of how to manage and release these items, it quickly became apparent that while the case for reuse was typically a slam dunk for utilities and frameworks, the data access objects just didn’t “smell” right.  We ended up having session after session of design meetings to try and find the right way to share these data access components. When someone asked me why it was taking so long to iron out the shared entities, my response was quite simple, “Reuse is hard...”  And that’s when I realized, that while reuse is an awesome goal and we should strive to make code maintainable, often times you end up creating far more work for yourself than necessary by trying to force code to be reusable that inherently isn’t. Think about classes the times you’ve worked in a company where in the design session people fight over the best way to implement a class to make it maximally reusable, extensible, and any other buzzwordable.  Then think about how quickly that design became obsolete.  Many times I set out to do a project and think, “yes, this is the best design, I can extend it easily!” only to find out the business requirements change COMPLETELY in such a way that the design is rendered invalid.  Code, in general, tends to rust and age over time.  As such, writing reusable code can often be difficult and many times ends up being a futile exercise and worse yet, sometimes makes the code harder to maintain because it obfuscates the design in the name of extensibility or reusability. So what do I think are reusable components? Generic Utility classes – these tend to be small classes that assist in a task and have no business context whatsoever. Implementation Abstraction Frameworks – home-grown frameworks that try to isolate changes to third party products you may be depending on (like writing a messaging abstraction layer for publishing/subscribing that is independent of whether you use JMS, MSMQ, etc). Simplification and Uniformity Frameworks – To some extent this is similar to an abstraction framework, but there may be one chosen provider but a development shop mandate to perform certain complex items in a certain way.  Or, perhaps to simplify and dumb-down a complex task for the average developer (such as implementing a particular development-shop’s method of encryption). And what are less reusable? Application and Business Layers – tend to fluctuate a lot as requirements change and new features are added, so tend to be an unstable dependency.  May be reused across applications but also very volatile. Entities and Data Access Layers – these tend to be tuned to the scope of the application, so reusing them can be hard unless the abstract is very stable. So what’s the big lesson?  Reuse is hard.  In fact it’s damn hard.  And much of the time I’m not convinced we should focus too hard on it. If you’re designing a utility or framework, then by all means design it for reuse.  But you most also really set down a good versioning, release, and documentation process to maximize your chances.  For anything else, design it to be maintainable and extendable, but don’t waste the effort on reusability for something that most likely will be obsolete in a year or two anyway.

    Read the article

  • TSM TDP for Exchange backup - ANS0326E

    - by Rhys
    Heres the stack Server - AIX - 5.3.0 BAclient - NT 32 bit 5.5.2.0 TDP for Exchange - 5.2.1 Backups are failing with ANS0326E (RC41) This node has exceeded its maximum number of moint points MAXNUMMP on the node is 1, which is the same as the other 2 exchange servers being backed up using this product. Only difference is that baclient version - on the working setup the baclient is at 5.4.0.2. Clues anyone?

    Read the article

  • Data Mining Software

    - by Mark
    I want to harvest some data like this http://www.newcardealers.ca/en/Dealers/List-A.aspx And insert the name, address, phone number, email, etc. into a database. Is there some software I can use that will take a webpage, let me specify some regexes or something, and then spit out all the matched data in a CSV or some format easily insertable into a DB?

    Read the article

  • Synaptics/usb mouse drivers data is invalid on win server 2003

    - by the wonderer
    Have just installed windows server 2003 image onto an HP laptop. Cannot get the mouse drivers to work. Have the correct drivers because I've extracted them out of a working PC (exact same model). I am always getting "Data is invalid". This is the synaptics touchpad drivers. Does anyone know how to fix this/ workaround to get mouse working? I have heard it may have something to do with permissions in the registry?

    Read the article

  • How to do jquery code AFTER page loading?

    - by Alex
    If you want an event to work on your page, you should call it inside the $(document).ready() function. Everything inside it will load as soon as the DOM is loaded and before the page contents are loaded. I want to do javascript code only after the page contents are loaded how can I do that?

    Read the article

  • To what degree should I use Marshal.ReleaseComObject with Excel Interop objects?

    - by DanM
    I've seen several examples where Marshal.ReleaseComObject() is used with Excel Interop objects (i.e., objects from namespace Microsoft.Office.Interop.Excel), but I've seen it used to various degrees. I'm wondering if I can get away with something like this: var application = new ApplicationClass(); try { // do work with application, workbooks, worksheets, cells, etc. } finally { Marashal.ReleaseComObject(application) } Or if I need to release every single object created, as in this method: public void CreateExcelWorkbookWithSingleSheet() { var application = new ApplicationClass(); var workbook = application.Workbooks.Add(_missing); var worksheets = workbook.Worksheets; for (var worksheetIndex = 1; worksheetIndex < worksheets.Count; worksheetIndex++) { var worksheet = (WorksheetClass)worksheets[worksheetIndex]; worksheet.Delete(); Marshal.ReleaseComObject(worksheet); } workbook.SaveAs( WorkbookPath, _missing, _missing, _missing, _missing, _missing, XlSaveAsAccessMode.xlExclusive, _missing, _missing, _missing, _missing, _missing); workbook.Close(true, _missing, _missing); application.Quit(); Marshal.ReleaseComObject(worksheets); Marshal.ReleaseComObject(workbook); Marshal.ReleaseComObject(application); } What prompted me to ask this question is that, being the LINQ devotee I am, I really want to do something like this: var worksheetNames = worksheets.Cast<Worksheet>().Select(ws => ws.Name); ...but I'm concerned I'll end up with memory leaks or ghost processes if I don't release each worksheet (ws) object. Any insight on this would be appreciated.

    Read the article

  • What are the semantics of [myThing.myProperty release]?

    - by dugla
    I clearly have not fully grocked properties. I have an instance of a class, myThing. myThing has a property that has be synthesized: // .h @property(nonatomic,retain)MyCoolType *coolType; // .m @synthesize coolType; In my program I call: // The retain count on MyCoolType is 1. [myThing.coolType release]; The reference count on MyCoolType is now zero and dealloc should fire. So, shouldn't myThing.coolType now be nil? In my code that is not the case. How do a correctly release and force the property to return nil? Thanks, Doug

    Read the article

  • Specific 'boot file' definition

    - by Jazz
    Hey, I have been given a general explanation of how a computer boots up. However a very loose definition to the term 'boot file' was given. Could someone explain 'boot file' to me in a very simple but concise manner? I have read about the POST, the clearing of registers, BIOS in the CMOS, etc. What I understand is that the boot file is different to the boot program. the boot program gets the system ready to accept an OS while the boot file contains some of the parameters by which the system will operate. The boot program is stored on ROM and the boot file isnt? cheers, jazz

    Read the article

  • storing multiple values as binary in one field

    - by Enghoej
    Hi I have a project where I need to store a large number of values. The data is a dataset holding 1024 2Byte Unsigned integer values. Now I store one value at one row together with a timestamp and a unik ID. This data is continously stored based on a time trigger. What I would like to do, is store all 1024 values in one field. So would it be possible to do some routine that stores all the 1024 2byte integer values in one field as binary. Maybe a blobfield. Thanks. Br. Enghoej

    Read the article

  • Form based authentication - Login get fails

    - by Sachin
    Hi All, I am using form based suthentication in my site. I have used one custom user control in my site which read items in sharepoint list and display it in a grid. Everything works fine with windows authentication but when I change the authentication to form based the login process get fails. I see the Error log it is giving me an error saying that "An SPRequest object was not disposed before the end of this thread" Then I have dispose all my spweb and spsite object that I have used in user control but still login process is not wotking. Thanks in advance

    Read the article

  • TFS build problem: missing assembly in test output folder

    - by Herman
    Hi all, I am trying to integrate unit test cases with a TFS build in our new solution. I've include the following configuration line in my TFSBuild.proj <ItemGroup> <TestContainer Include="$(OutDir)\%2aTest.dll" /> </ItemGroup> Which I think is the correct configuration since I only have 1 test project. However, when I do this, some dll is missing in the output folder of the test case, hence failing most of my test case. Has anyone run into this problem before? Thanks!

    Read the article

  • MySQL GIS and Spatial Extensions - how to map regions and query against them

    - by chibineku
    I am trying to make a smartphone app which will return a list of users within a certain proximity, say 100m. It's easy to get the coordinates of my BlackBerry and write them to a database, but in order to return a list of other users within 100m, I need to pull every other record from the database and compare the distance between the two points, checking to see if it's within range, before outputting that user's information. This is going to be time consuming if there are many users involved. So I would like to map areas (countries, cities, I'm not yet sure of the resolution I'll need) so that I can first target a smaller subset of all users. This will save on processing time. I have read the basics of GIS and spatial querying on the mysql website but to be honest the query is over my head and I hate copying and pasting code without understanding it. Plus it only checks for proximity - I want to first check if a coordinate falls within a certain area. Does anyone have any experience of such matters and feel like giving me some pointers? Resources such as any preexisting databases of points describing countries as polygons would be really helpful too. Many thanks to anyone who takes the time :)

    Read the article

  • Whats wrong with this ASP.NET rewrite?

    - by acidzombie24
    Actually its the mono version of asp.net, XSP. In my begin request function i check the url and rewrite when necessary. In one case i do context.RewritePath("~/App_Data/public" + path); When i try to request images or anything i get a 404 instead of the content. Why?

    Read the article

  • ASP.NET MVC: Routing

    - by JamesBrownIsDead
    Let's say I have this Controller: public class GlobalizationController : Controller { public JavaScriptResult GlobalizedLabels(string virtualPath) { return new JavaScriptResult(); } } I want the controller to handle (i.e. invoke from) any of the relative URLs below: /globalization/~Enlargement/Controls/Container.ascx /globalization/test/foobar.aspx /globalization/HappyTimes/Are/Right/Now What would my entry in global.asax routes.MapRoute() entry look like? As in... routes.MapRoute("Globalization", "globalization/{virtualPath}", new { controller = "Globalization", action = "GlobalizedLabels" }); The URL pattern "{virtualPath}" is wrong. What should it be?

    Read the article

  • How can I implement a volume meter for a song currently playing? (iPhone OS 3.1.3)

    - by Adam
    Hi i'm very new to core audio and I just would like some help in coding up a little volume meter for whatever's being outputted through headphones or built-in speaker. Like a dB meter. I have the following code, and have been trying to go through the apple source project "SpeakHere", but it's a nightmare trying to go through all that, without knowing how it works first... Could anyone shed some light? Here's the code I have so far... (void)displayWaveForm { while (musicIsPlaying == YES { NSLog(@"%f",sizeof(AudioQueueLevelMeterState)); } } (IBAction)playMusic { if (musicIsPlaying == NO) { NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/track7.wav",[[NSBundle mainBundle] resourcePath]]]; NSError *error; music = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error]; music.numberOfLoops = -1; music.volume = 0.5; [music play]; musicIsPlaying = YES; [self displayWaveForm]; } else { [music pause]; musicIsPlaying = NO; } }

    Read the article

  • How to search in this activerecord example?

    - by Horace Ho
    Two models: Invoice :invoice_num string :date datetime . . :disclaimer_num integer (foreign key) Disclaimer :disclaimer_num integer :version integer :body text For each disclaimer there are multiple versions and will be kept in database. This is how I write the search (simplified): scope = Invoice.scoped({ :joins => [:disclaimer] }) scope = scope.scoped :conditions => ["Invoice.invoice_num = ?", "#{params[:num]}"] scope = scope.scoped :conditions => ["Disclaimer.body LIKE ?", "%#{params[:text]}%"] However, the above search will search again all versions of the disclaimer. How can I limit the search to only the last disclaimer (i.e. the version integer is the maximum). Please note: Invoice does not keep the version number. New disclaimers will be added to disclaimer table and keep old versions.

    Read the article

  • Is there a way to bypass the jQuery error handler?

    - by oravecz
    If my Ajax call returns a successful result, but while processing the result I cause an exception, the error handler fires. This seems counter intuitive to me as I think the error handler should only fire when an error occurs as a result of making the Ajax call or via a server-side error. I am trying to use the Ajax function in a unit test so I would like to tell the difference between the two different failure scenarios.

    Read the article

  • for line in open(filename)

    - by foosion
    I frequently see python code similar to for line in open(filename): do_something(line) When does filename get closed with this code? Would it be better to write with open(filename) as f: for line in f.readlines(): do_something(line)

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >