Search Results

Search found 15698 results on 628 pages for 'keep alive'.

Page 41/628 | < Previous Page | 37 38 39 40 41 42 43 44 45 46 47 48  | Next Page >

  • how do i keep form data after submitting the form using javascript?

    - by Lina
    When i submit this form, the values just disappears from the textboxes. I like them to stay printed in the textboxes. How do i do that? <form id="myform" method="get" action="" onSubmit="hello();"> <input id="hour" type="text" name="hour" style="width:30px; text-align:center;" /> : <input id="minute" type="text" name="minute" style="width:30px; text-align:center;" /> <br/> <input type="submit" value="Validate!" /> </form> <style type="text/css"> .error { color: red; font: 10pt verdana; padding-left: 10px } </style> <script type="text/javascript"> function hello(){ var hour = $("#hour").html(); alert(hour); } $(function() { // validate contact form on keyup and submit $("#myform").validate({ //set the rules for the fild names rules: { hour: { required: true, minlength: 1, maxlength: 2, range:[0,23] }, minute: { required: true, minlength: 1, maxlength: 2, range:[0,60] }, }, //set messages to appear inline messages: { hour: "Please enter a valid hour", minute: "Please enter a valid minute" } }); }); </script>

    Read the article

  • How to keep views free of authorization logic in mvc?

    - by David Lay
    I have a view to display a list of items. The user can edit, delete or create new items, but according to their authorizations they may or may not be allowed to do some of this actions. I have the requirement to display only the actions which the current user is allowed to do, but I don't want to clutter the views with authorization if-else's Despise of being a very common requirement, I can't find a real satisfactory way of doing it. My best approach so far is to provide an overload to the Html.ActionLink extension method that takes the permission to ask for, but there are going to be more complex scenarios, like hiding entire blocks of html or switching a textbox for a label+hidden. Is there a better way to do this?

    Read the article

  • Do you have any tips for comments to keep them in step with the code? [closed]

    - by Rob Wells
    Possible Duplicate: How do you like your comments? G'day, I've read both of Steve McConnell's excellent Code Complete books "Code Complete" and "Code Complete 2" and was wondering if people have any other suggestions for commenting code. My commenting mantra could be summed up by the basic idea of expressing "what the code below cannot say". While enjoying this interesting blog post by Jeff about commenting I was still left wondering "When coding, when do you feel a comment is required?" Edit: Oops. Seems to be a duplicate of this question http://stackoverflow.com/questions/121945/how-do-you-like-your-comments so sorry for the noise. Thanks to my, seemingly, SO shadow for pointing it out - wouldn't have thought I was that interesting. Now off to read the original post and see if it is relevant. Edit: I meant to emphasise the best appraoch to ensure that your comments will stay in step with the code. Maybe expressing an intent rather than the mechansim for instance.

    Read the article

  • Delphi - Why does ExplicitWidth and ExplicitHeight keep appearing in .DFM files and what is it!?

    - by Pauk
    We've noticed that when checking in updates that our .DFM files have had ExplicitWidth and ExplicitHeight properties added for what appears to be no particular reason. My two questions are, what are they for and why do they get automatically added by Delphi? Below is an example with the property in: object Splitter2: TcxSplitter Left = 0 Top = 292 Width = 566 Height = 8 Cursor = crVSplit HotZoneClassName = 'TcxXPTaskBarStyle' AlignSplitter = salBottom Control = BottomPanel Color = clBtnFace ExplicitWidth = 8 end

    Read the article

  • (resolved) empty response body in ajax (or 206 Partial Content)

    - by Nikita Rybak
    Hi guys, I'm feeling completely stupid because I've spent two hours solving task which should be very simple and which I solved many times before. But now I'm not even sure in which direction to dig. I fail to fetch static content using ajax from local servers (Apache and Mongrel). I get responses 200 and 206 (depending on the server), empty response text (although Content-Length header is always correct), firebug shows request in red. Javascript is very generic, I'm getting same results even here: http://www.w3schools.com/ajax/tryit.asp?filename=tryajax_first (just change document location to 'http://localhost:3000/whatever') So, it's probably not the cause. Well, now I'm out of ideas. I can also post http headers, if it'll help. Thanks! Response Headers Connection close Date Sat, 01 May 2010 21:05:23 GMT Last-Modified Sun, 18 Apr 2010 19:33:26 GMT Content-Type text/html Content-Length 7466 Request Headers Host localhost:3000 User-Agent Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language en-us,en;q=0.5 Accept-Encoding gzip,deflate Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive 115 Connection keep-alive Referer http://www.w3schools.com/ajax/tryit_view.asp Origin http://www.w3schools.com Response Headers Date Sat, 01 May 2010 21:54:59 GMT Server Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8l DAV/2 mod_jk/1.2.28 Etag "3d5cbdb-fb4-4819c460d4a40" Accept-Ranges bytes Content-Length 4020 Cache-Control max-age=7200, public, proxy-revalidate Expires Sat, 01 May 2010 23:54:59 GMT Content-Range bytes 0-4019/4020 Keep-Alive timeout=5, max=100 Connection Keep-Alive Content-Type application/javascript Request Headers Host localhost User-Agent Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language en-us,en;q=0.5 Accept-Encoding gzip,deflate Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive 115 Connection keep-alive Origin null UPDATED: I've found a problem, it was about cross-domain requests. I knew that there are restrictions, but thought they're relaxed for local filesystem and local servers. (and expected more descriptive error message, anyway) Thanks everybody!

    Read the article

  • VS2010: Why do my custom Toolbox tabs and contained controls keep disappearing?

    - by Velika2
    This is how I expected the toolbox to work: Let's say I add a custom Tab to the Toolbox called "Ajaxtoolkit." To add controls to the new tab, I right mouse click and select "Choose Items" and browse to a file, Ajaxtoolkit.dll, that is of a particular version number. I would expect that when I save and reopen the solution, that the Ajax Toolkit custom tab would still be in my Toolbox and that it would contain the same controls that were there last time, the controls that were in the dll that I referenced when the controls were added. If I created a brand new web app, I (possibly) wouldn't expect to see the same Ajax Toolkit custom tab. However, I could perform the same steps as above and add a "Ajax Toolkit" tab and perhaps, this time, select a DIFFERENT VERSION of the tookit, and the state of the toolkit would be retained with each solution file. Another possibility would be for the original Ajaxtoolkit to be retained when the 2nd web solution is created, and perhaps, if I wanted to mix versions of the toolkit across diffreent web sites in my solution, I should start naming my custom toolkit tabs with version specific names like "Ajaxtoolkit 4.0," etc. ...But instead, the Ajaxtoolkit tab disappears when I close VS2010 and reopen it. Why? Is this desirable behavior or a bug?

    Read the article

  • PHP File Serving Script: Unreliable Downloads?

    - by JGB146
    This post started as a question on ServerFault ( http://serverfault.com/questions/131156/user-receiving-partial-downloads ) but I determined that our php script was the culprit. So I'm issuing an updated question here about what I believe is the actual issue. I am using a php script to verify permissions and then serve up a file for users of my website to download. Most of the time, this works, but recently one user has been seeing problems with larger downloads. He is only getting ~80% of downloads for files that are 100MB in size. Also, all downloads from this script fail to report a filesize. Further, tests revealed that the same user COULD reliably download each of the failed files if given a direct link (at which point the filesize is reported). Here's the relevant snippet of code that we are using to serve the file: header("Content-type:$contenttype"); $len = filesize($filename); header("Content-Length: $len"); header("Content-Disposition: attachment; filename=".$title.".".$ext); readfile($filename); Note that $contenttype, $filename, $title, and $ext are all set correctly before we get here. These have been triple-checked. None of them are the problem. Also, $len does provide the correct filesize. While researching this issue, I came across this post: http://stackoverflow.com/questions/1334471/content-length-header-always-zero It seems that I am encountering the same issue. When I use the script, I get chunked encoding on the file and no size is set for content-length. I'm hypothesizing that something is going wrong on the large downloads, leading him to get a zero-length chunk before the end of the file. Here's what the headers look like for a direct request: http://www.grinderschool.com/videos/zfff5061b65ae00e8b21/KillsAids021.wmv GET /videos/zfff5061b65ae00e8b21/KillsAids021.wmv HTTP/1.1 Host: www.grinderschool.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729) Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 115 Connection: keep-alive Referer: http://www.grinderschool.com/phpBB3/viewtopic.php?f=14&p=29468 Cookie: style_cookie=printonly; phpbb3_7c544_u=2; phpbb3_7c544_k=44b832912e5f887d; phpbb3_7c544_sid=e8852df42e08cc1b2250300c2897f78f; __utma=174624884.2719561324781918700.1251850714.1270986325.1270989003.575; __utmz=174624884.1264524375.411.12.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=low%20stakes%20poker%20videos; phpbb3_cmviy_k=; phpbb3_cmviy_u=2; phpbb3_cmviy_sid=d8df5c0943863004ca40ef9c392d371d; __utmb=174624884.4.10.1270989003; __utmc=174624884 Pragma: no-cache Cache-Control: no-cache HTTP/1.1 200 OK Date: Sun, 11 Apr 2010 12:57:41 GMT Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8l DAV/2 mod_auth_passthrough/2.1 FrontPage/5.0.2.2635 Last-Modified: Sun, 04 Apr 2010 12:51:06 GMT Etag: "eb42d6-7d9b843-48368aa6dc280" Accept-Ranges: bytes Content-Length: 131708995 Keep-Alive: timeout=10, max=30 Connection: Keep-Alive Content-Type: video/x-ms-wmv And here's what they look like for the request answered by my script: http://www.grinderschool.com/download_video_test.php?t=KillsAids021&format=wmv GET /download_video_test.php?t=KillsAids021&format=wmv HTTP/1.1 Host: www.grinderschool.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729) Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 115 Connection: keep-alive Cookie: style_cookie=printonly; phpbb3_7c544_u=2; phpbb3_7c544_k=44b832912e5f887d; phpbb3_7c544_sid=e8852df42e08cc1b2250300c2897f78f; __utma=174624884.2719561324781918700.1251850714.1270986325.1270989003.575; __utmz=174624884.1264524375.411.12.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=low%20stakes%20poker%20videos; phpbb3_cmviy_k=; phpbb3_cmviy_u=2; phpbb3_cmviy_sid=d8df5c0943863004ca40ef9c392d371d; __utmb=174624884.4.10.1270989003; __utmc=174624884 HTTP/1.1 200 OK Date: Sun, 11 Apr 2010 12:58:02 GMT Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8l DAV/2 mod_auth_passthrough/2.1 FrontPage/5.0.2.2635 X-Powered-By: PHP/5.2.11 Content-Disposition: attachment; filename=KillsAids021.wmv Vary: Accept-Encoding Content-Encoding: gzip Keep-Alive: timeout=10, max=30 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: video/x-ms-wmv So the question is...what can I do to make downloads from the script work properly? Again, for 99% of users, it works as is (though I find it annoying now that no filesize is reported and thus that no time estimate can be computed about the download).

    Read the article

  • TransactionScope question - how can I keep the DTC from getting involved in this?

    - by larryq
    (I know the circumstances surrounding the DTC and promoting a transaction can be a bit mysterious to those of us not in the know, but let me show you how my company is doing things, and if you can tell me why the DTC is getting involved, and if possible, what I can do to avoid it, I'd be grateful.) I have code running on an ASP.Net webserver. We have one database, SQL 2008. Our data access code looks something like this-- We have a data access layer that uses a wrapper object for SQLConnections and SQLCommands. Typical use looks like this: void method1() { objDataObject = new DataAccessLayer(); objDataObject.Connection = SomeConnectionMethod(); SqlCommand objCommand = DataAccessUtils.CreateCommand(SomeStoredProc); //create some SqlParameters, add them to the objCommand, etc.... objDataObject.BeginTransaction(IsolationLevel.ReadCommitted); objDataObject.ExecuteNonQuery(objCommand); objDataObject.CommitTransaction(); objDataObject.CloseConnection(); } So indeed, a very thin wrapper around SqlClient, SqlConnection etc. I want to run several stored procs in a transaction, and the wrapper class doesn't allow me access to the SqlTransaction so I can't pass it from one component to the next. This led me to use a TransactionScope: using (TransactionScope tx1 = new TransactionScope(TransactionScope.RequiresNew)) { method1(); method2(); method3(); tx1.Complete(); } When I do this, the DTC gets involved, and unfortunately our webservers don't have "allow remote clients" enabled in the MSDTC settings-- getting IT to allow that will be a fight. I'd love to avoid DTC becoming involved but can I do it? Can I leave out the transactional calls in methods1-3() and just let the TransactionScope figure it all out?

    Read the article

  • How to keep multiple connectionString passwords safe, separate, and easy to deploy?

    - by Funka
    I know there are plenty of questions here already about this topic (I've read through as many as I could find), but I haven't yet been able to figure out how best to satisfy my particular criteria. Here are the goals: The ASP.NET application will run on a few different web servers, including localhost workstations for development. This means encrypting web.config using a machine key is out. The application will decide which connection string to use based on the server name (using a switch statement). For example, "localhost" and "dev.example.com" will use the DevDatabaseConnectionString, "test.example.com" will use the TestDatabaseConnectionString, and "www.example.com" will use the ProdDatabaseConnectionString, for example. Ideally, the exact same executables and web.config should be able to run on any of these environments, without needing to tailor or configure each environment separately every time that we deploy (something that seems like it would be easy to forget/mess up one day during a deployment, which is why we moved away from having just one connectionstring that has to be changed on each target). Deployment is currently accomplished via FTP. We will not have command-line access to the production web server. This means using aspnet_regiis.exe is out. (I could run on localhost, however, if this would still work.) We would prefer to not have to recompile the application whenever a password changes, so using web.config (or db.config or whatever) seems to make the most sense. A developer should not be able to decrypt the production database password. If a developer checks the source code out onto their localhost laptop (which would determine that it should be using the DevDatabaseConnectionString, remember?) and the laptop gets lost or stolen, it should not be possible to get at the other connection strings. Thus, having a single RSA private key to un-encrypt all three passwords cannot be considered. (Contrary to #3 above, it does seem like we'd need to have three separate key files if we went this route; these could be installed once per machine, and should the wrong key file get deployed to the wrong server, the worst that should happen is that the app can't decrypt anything---and not allow the wrong host to access the wrong database!) I know this is probably a subjective question (asking for a "best" way to do something), but given the criteria I've mentioned, I'm hoping that a single best answer will indeed arise. Thank you!

    Read the article

  • How can I keep a graphics object centered (like a circle) when zooming in or out on it?

    - by sonny5
    using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Drawing.Drawing2D; using System.Drawing.Imaging; namespace testgrfx { public class Form1 : System.Windows.Forms.Form { float m_Scalef; float m_Scalefout; Rectangle m_r1; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button3; private System.ComponentModel.Container components = null; private void InitializeComponent() { m_Scalef = 1.0f; // for zooming purposes Console.WriteLine("opening m_Scalef= {0}",m_Scalef); m_Scalefout = 1.0f; Console.WriteLine("opening m_Scalefout= {0}",m_Scalefout); m_r1 = new Rectangle(50,50,100,100); this.AutoScrollMinSize = new Size(600,700); this.components = new System.ComponentModel.Container(); this.button2 = new System.Windows.Forms.Button(); this.button2.BackColor = System.Drawing.Color.LightGray; this.button2.Location = new System.Drawing.Point(120, 30); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(72, 24); this.button2.TabIndex = 1; this.button2.Text = "Zoom In"; this.button2.Click += new System.EventHandler(this.mnuZoomin_Click); this.Controls.Add(button2); this.button3 = new System.Windows.Forms.Button(); this.button3.BackColor = System.Drawing.Color.LightGray; this.button3.Location = new System.Drawing.Point(200, 30); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(72, 24); this.button3.TabIndex = 2; this.button3.Text = "Zoom Out"; this.button3.Click += new System.EventHandler(this.mnuZoomout_Click); this.Controls.Add(button3); //InitMyForm(); } public Form1() { InitializeComponent(); Text = " DrawLine"; BackColor = SystemColors.Window; // Gotta load these kind at start-up ... not with button assignments this.Paint+=new PaintEventHandler(this.Form1_Paint); } static void Main() { Application.Run(new Form1()); } /// Clean up any resources being used. protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } // autoscroll2.cs does work private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { Graphics dc = e.Graphics; dc.PageUnit = GraphicsUnit.Pixel; dc.PageScale = m_Scalef; Console.WriteLine("opening dc.PageScale= {0}",dc.PageScale); dc.TranslateTransform(this.AutoScrollPosition.X/m_Scalef, this.AutoScrollPosition.Y/m_Scalef); Pen pn = new Pen(Color.Blue,2); dc.DrawEllipse(pn,m_r1); Console.WriteLine("form_paint_dc.PageUnit= {0}",dc.PageUnit); Console.WriteLine("form_paint_dc.PageScale= {0}",dc.PageScale); //Console.Out.NewLine = "\r\n\r\n"; // makes all double spaces } private void mnuZoomin_Click(object sender, System.EventArgs e) { m_Scalef = m_Scalef * 2.0f; Console.WriteLine("in mnuZoomin_Click m_Scalef= {0}",m_Scalef); Invalidate(); // to trigger Paint of entire client area } // try: System.Drawing.Rectangle resolution = Screen.GetWorkingArea(someForm); private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { // Uses the mouse wheel to scroll Graphics dc = CreateGraphics(); dc.TranslateTransform(this.AutoScrollPosition.X/m_Scalef, this.AutoScrollPosition.Y/m_Scalef); Console.WriteLine("opening Form1_MouseDown dc.PageScale= {0}", dc.PageScale); Console.WriteLine("Y wheel= {0}", this.AutoScrollPosition.Y/m_Scalef); dc.PageUnit = GraphicsUnit.Pixel; dc.PageScale = m_Scalef; Console.WriteLine("frm1_moudwn_dc.PageScale= {0}",dc.PageScale); Point [] mousep = new Point[1]; Console.WriteLine("mousep= {0}", mousep); // make sure to adjust mouse pos.for scroll position Size scrollOffset = new Size(this.AutoScrollPosition); mousep[0] = new Point(e.X-scrollOffset.Width, e.Y-scrollOffset.Height); dc.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Device,mousep); Pen pen = new Pen(Color.Green,1); dc.DrawRectangle(pen,m_r1); Console.WriteLine("m_r1= {0}", m_r1); Console.WriteLine("mousep[0].X= {0}", mousep[0].X); Console.WriteLine("mousep[0].Y= {0}", mousep[0].Y); if (m_r1.Contains(new Rectangle(mousep[0].X, mousep[0].Y,1,1))) MessageBox.Show("click inside rectangle"); } private void Form1_Load(object sender, System.EventArgs e) { } private void mnuZoomout_Click(object sender, System.EventArgs e) { Console.WriteLine("first line--mnuZoomout_Click m_Scalef={0}",m_Scalef); if(m_Scalef > 9 ) { m_Scalef = m_Scalef / 2.0f; Console.WriteLine("in >9 mnuZoomout_Click m_Scalef= {0}",m_Scalef); Console.WriteLine("in >9 mnuZoomout_Click__m_Scalefout= {0}",m_Scalefout); } else { Console.WriteLine("<= 9_Zoom-out B-4 redefining={0}",m_Scalef); m_Scalef = m_Scalef * 0.5f; // make it same as previous Zoom In Console.WriteLine("<= 9_Zoom-out after m_Scalef= {0}",m_Scalef); } Invalidate(); } } // public class Form1 }

    Read the article

  • How to keep iPhone app out of iPad store?

    - by Eric
    I have an iPhone app that I have started to turn into a universal app, however the process is not complete and I want to release an update to the iPhone version. I know that you can specify device capabilities in the Info.plist file to restrict your app to certain devices, but how can I do this to prevent the unfinished universal version from appearing in the iPad store? Is checking the LSRequiresiPhoneOS BOOL entry (in the Info.plist file) enough? Thanks!

    Read the article

  • How to keep your unit test Arrange step simple and still guarantee DDD invariants ?

    - by ian31
    DDD recommends that the domain objects should be in a valid state at any time. Aggregate roots are responsible for guaranteeing the invariants and Factories for assembling objects with all the required parts so that they are initialized in a valid state. However this seems to complicate the task of creating simple, isolated unit tests a lot. Let's assume we have a BookRepository that contains Books. A Book has : an Author a Category a list of Bookstores you can find the book in These are required attributes : a book has to have an author, a category and at least a book store you can buy the book from. There's likely to be a BookFactory since it is quite a complex object, and the Factory will initialize the Book with at least all the mentioned attributes. Now we want to unit test a method of the BookRepository that returns all the Books. To test if the method returns the books, we have to set up a test context (the Arrange step in AAA terms) where some Books are already in the Repository. If the only tool at our disposal to create Book objects is the Factory, the unit test now also uses and is dependent on the Factory and inderectly on Category, Author and Store since we need those objects to build up a Book and then place it in the test context. Would you consider this is a dependency in the same way that in a Service unit test we would be dependent on, say, a Repository that the Service would call ? How would you solve the problem of having to re-create a whole cluster of objects in order to be able to test a simple thing ? How would you break that dependency and get rid of all these attributes we don't need in our test ? By using mocks or stubs ? If you mock up things a Repository contains, what kind of mock/stubs would you use as opposed to when you mock up something the object under test talks to or consumes ?

    Read the article

  • How to keep your unit tests simple and isolated and still guarantee DDD invariants ?

    - by ian31
    DDD recommends that the domain objects should be in a valid state at any time. Aggregate roots are responsible for guaranteeing the invariants and Factories for assembling objects with all the required parts so that they are initialized in a valid state. However this seems to complicate the task of creating simple, isolated unit tests a lot. Let's assume we have a BookRepository that contains Books. A Book has : an Author a Category a list of Bookstores you can find the book in These are required attributes : a book has to have an author, a category and at least a book store you can buy the book from. There's likely to be a BookFactory since it is quite a complex object, and the Factory will initialize the Book with at least all the mentioned attributes. Now we want to unit test a method of the BookRepository that returns all the Books. To test if the method returns the books, we have to set up a test context (the Arrange step in AAA terms) where some Books are already in the Repository. If the only tool at our disposal to create Book objects is the Factory, the unit test now also uses and is dependent on the Factory and inderectly on Category, Author and Store since we need those objects to build up a Book and then place it in the test context. Would you consider this is a dependency in the same way that in a Service unit test we would be dependent on, say, a Repository that the Service would call ? How would you solve the problem of having to re-create a whole cluster of objects in order to be able to test a simple thing ? How would you break that dependency and get rid of all these attributes we don't need in our test ? By using mocks or stubs ? If you mock up things a Repository contains, what kind of mock/stubs would you use as opposed to when you mock up something the object under test talks to or consumes ?

    Read the article

  • c++ - strange problem with polymorphism - cellular automaton

    - by Green
    Hello, I am making "game of life" implementation that, when cell has: two live neighbours I make object of class CCellB two live neighbours I make object of class CCellA when has 3 or <2 I make object of class CCellX (dead) Class CCell is base of CCellA, CCellB, CCellX My problem is: That works fine, until I change new CCell(); to new CCellB();: CCell ***temp = allocateArray(); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { c = arr[i][j]->countAliveNeighbor(); if(c == 3) { temp[i][j] = new CCellA(); temp[i][j]->alive = 1; }else if(c == 2) { temp[i][j] = new CCell(); // HERE, WHEN I CHANGE IT TO CCELLB IT DON'T WORKS temp[i][j]->alive = tab[i][j]->alive; }else if((c >= 4)||(c < 2)) { temp[i][j] = new CCellX(); } } } Then it seems don't work properly... Seems like neighbours are not count properly, Cell with 4,5 neighbours still alive alive var is member of base class - CCell, all is public, please help!

    Read the article

  • how to handle it if the management just keep on giving me spec after spec non-stop?

    - by Jian Lin
    As a programmer, I feel burnt out if the management give me spec after spec, day after day. I think I can code 6 hours a day very focused, but non-stop coding does burn me out a little, especially it is 1 year or 18 months non-stop. A mere 1 week or 2 week vacation per year isn't going to help much. Sometimes I want to take some time to learn new things, or just to take a break for a month so as to re-charge, like back in college when we have holidays for 1 month during winter or 2.5 months during summer. What do you think?

    Read the article

  • How to keep a local value from being set when a binding fails (so inherited values will propagate)

    - by redoced
    Consider the following scenario: I want to bind the TextElement.FontWeight property to an xml attribute. The xml looks somewhat like this and has arbitrary depth. <text font-weight="bold"> bold text here <inlinetext>more bold text</inlinetext> even more bold text </text> I use hierarchical templating to display the text, no problem there, but having a Setter in the template style like: <Setter Property="TextElement.FontWeight" Value="{Binding XPath=@font-weight}"/> sets the fontweight correctly on the first level, but overwrites the second level with null (as the binding can't find the xpath) which reverts to Fontweight normal. I tried all sorts of things here but nothing quite seems to work. e.g. i used a converter to return UnsetValue, which didn't work. I'm currently trying with: <Setter Property="custom:AttributeInserter.Wrapper" Value="{custom:AttributeInserter Property=TextElement.FontWeight, Binding={Binding XPath=@font-weight}}"/> Codebehind: public static class AttributeInserter { public static AttributeInserterExtension GetWrapper(DependencyObject obj) { return (AttributeInserterExtension)obj.GetValue(WrapperProperty); } public static void SetWrapper(DependencyObject obj, AttributeInserterExtension value) { obj.SetValue(WrapperProperty, value); } // Using a DependencyProperty as the backing store for Wrapper. This enables animation, styling, binding, etc... public static readonly DependencyProperty WrapperProperty = DependencyProperty.RegisterAttached("Wrapper", typeof(AttributeInserterExtension), typeof(AttributeInserter), new UIPropertyMetadata(pcc)); static void pcc(DependencyObject o,DependencyPropertyChangedEventArgs e) { var n=e.NewValue as AttributeInserterExtension; var c = o as FrameworkElement; if (n == null || c==null || n.Property==null || n.Binding==null) return; var bex = c.SetBinding(n.Property, n.Binding); bex.UpdateTarget(); if (bex.Status == BindingStatus.UpdateTargetError) c.ClearValue(n.Property); } } public class AttributeInserterExtension : MarkupExtension { public override object ProvideValue(IServiceProvider serviceProvider) { return this; } public DependencyProperty Property { get; set; } public Binding Binding { get; set; } } which kinda works, but can't track changes of the property Any ideas? Any links? thx for the help

    Read the article

  • How do I keep a scanner from throwing exceptions when the wrong type is entered? (java)

    - by David
    Here's some sample code: import java.util.Scanner; class In { public static void main (String[]arg) { Scanner in = new Scanner (System.in) ; System.out.println ("how many are invading?") ; int a = in.nextInt() ; System.out.println (a) ; } } if i run the program and give it an int like 4then everything goes fine. if, on the other hand, i answer too many it doesn't laugh at my funny joke. instead i get this: (as expected) Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor(Scanner.java:819) at java.util.Scanner.next(Scanner.java:1431) at java.util.Scanner.nextInt(Scanner.java:2040) at java.util.Scanner.nextInt(Scanner.java:2000) at In.main(In.java:9) is there a way so that i can make it so that it either ignores entries that aren't ints or re prompts with "how many are invading?"? i'd like to know how to do both of these.

    Read the article

  • Google Analytics - Goals - Advanced Segments - Does it keep cookies for tracking visitors?

    - by Kuko
    Hi there, I am working with Google Analytics - Goals and Funnels for quite sometime, but one thing is is not clear for me. I would very much appreciate if you could help me. We are advertising on several sites rotating several different ads. Our main goal is to collect as many sign-ups (new users) as possible for as low price as possible. We use to advertise the way, that each ad has the same URL where to land, but contains different parameter (e.g. http://www.brautpunkt.de/?ref=fb01 or ..... .de/?ref=adw03). My question is: If I am looking at the goals (Goals Overview), filtering it through Advanced Segments (Landing Page contains /?ref=fb01) is this subset of goals done only by the users who registered in the same session after they came on our site directly from the ad? or also by those users who came first time through this ad (/?ref=fb01), didn't register in the same session but came directly for example on the other day and register than? Thank you very much in advance for your advice. Peter

    Read the article

< Previous Page | 37 38 39 40 41 42 43 44 45 46 47 48  | Next Page >