Search Results

Search found 5483 results on 220 pages for 'logic artist'.

Page 9/220 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Conditions with common logic: question of style, readability, efficiency, ...

    - by cdonner
    I have conditional logic that requires pre-processing that is common to each of the conditions (instantiating objects, database lookups etc). I can think of 3 possible ways to do this, but each has a flaw: Option 1 if A prepare processing do A logic else if B prepare processing do B logic else if C prepare processing do C logic // else do nothing end The flaw with option 1 is that the expensive code is redundant. Option 2 prepare processing // not necessary unless A, B, or C if A do A logic else if B do B logic else if C do C logic // else do nothing end The flaw with option 2 is that the expensive code runs even when neither A, B or C is true Option 3 if (A, B, or C) prepare processing end if A do A logic else if B do B logic else if C do C logic end The flaw with option 3 is that the conditions for A, B, C are being evaluated twice. The evaluation is also costly. Now that I think about it, there is a variant of option 3 that I call option 4: Option 4 if (A, B, or C) prepare processing if A set D else if B set E else if C set F end end if D do A logic else if E do B logic else if F do C logic end While this does address the costly evaluations of A, B, and C, it makes the whole thing more ugly and I don't like it. How would you rank the options, and are there any others that I am not seeing?

    Read the article

  • What is the best way to handle this type of inclusive logic in Ruby?

    - by Steve McLelland
    Is there a better way of handling this in Ruby, while continuing to use the symbols? pos = :pos1 # can be :pos2, :pos3, etc. if pos == :pos1 || pos == :pos2 || pos == :pos3 puts 'a' end if pos == :pos1 || pos == :pos2 puts 'b' end if pos == :pos1 puts 'c' end The obvious way would be swapping out the symbols for number constants, but that's not an option. pos = 3 if pos >= 1 puts 'a' end if pos >= 2 puts 'b' end if pos >= 3 puts 'c' end Thanks.

    Read the article

  • Where do I put the logic of my MFC program?

    - by Matthew
    I created an application core, in C++, that I've compiled into a static library in Visual Studio. I am now at the process of writing a GUI for it. I am using MFC to do this. I figured out how to map button presses to execute certain methods of my application core's main class (i.e. buttons to have it start and stop). The core class however, should always be sampling data from an external source every second or two. The GUI should then populate some fields after each sample is taken. I can't seem to find a spot in my MFC objects like CDialog that I can constantly check to see if my class has grabbed the data.. then if it has put that data into some of the text boxes. A friend suggested that I create a thread on the OnInit() routine that would take care of this, but that solution isn't really working for me. Is there no spot where I can put an if statement that keeps being called until the program quits? i.e. if( coreapp.dataSampleReady() ) { // put coreapp.dataItem1() in TextBox1 // set progress bar to coreapp.dataItem2() // etc. // reset dataSampleReady }

    Read the article

  • Create a model that switches between two different states using Temporal Logic?

    - by NLed
    Im trying to design a model that can manage different requests for different water sources. Platform : MAC OSX, using latest Python with TuLip module installed. For example, Definitions : Two water sources : w1 and w2 3 different requests : r1,r2,and r3 - Specifications : Water 1 (w1) is preferred, but w2 will be used if w1 unavailable. Water 2 is only used if w1 is depleted. r1 has the maximum priority. If all entities request simultaneously, r1's supply must not fall below 50%. - The water sources are not discrete but rather continuous, this will increase the difficulty of creating the model. I can do a crude discretization for the water levels but I prefer finding a model for the continuous state first. So how do I start doing that ? Some of my thoughts : Create a matrix W where w1,w2 ? W Create a matrix R where r1,r2,r3 ? R or leave all variables singular without putting them in a matrix I'm not an expert in coding so that's why I need help. Not sure what is the best way to start tackling this problem. I am only interested in the model, or a code sample of how can this be put together. edit Now imagine I do a crude discretization of the water sources to have w1=[0...4] and w2=[0...4] for 0, 25, 50, 75,100 percent respectively. == means implies Usage of water sources : if w1[0]==w2[4] -- meaning if water source 1 has 0%, then use 100% of water source 2 etc if w1[1]==w2[3] if w1[2]==w2[2] if w1[3]==w2[1] if w1[4]==w2[0] r1=r2=r3=[0,1] -- 0 means request OFF and 1 means request ON Now what model can be designed that will give each request 100% water depending on the values of w1 and w2 (w1 and w2 values are uncontrollable so cannot define specific value, but 0...4 is used for simplicity )

    Read the article

  • Learning Java and logic using debugger. Did I cheat?

    - by centr0
    After a break from coding in general, my way of thinking logically faded (as if it was there to begin with...). I'm no master programmer. Intermediate at best. I decided to see if i can write an algorithm to print out the fibonacci sequence in Java. I got really frustrated because it was something so simple, and used the debugger to see what was going on with my variables. solved it in less than a minute with the help of the debugger. Is this cheating? When I read code either from a book or someone else's, I now find that it takes me a little more time to understand. If the alghorithm is complex (to me) i end up writing notes as to whats going on in the loop. A primitive debugger if you will. When you other programmers read code, do you also need to write things down as to whats the code doing? Or are you a genius and and just retain it?

    Read the article

  • How much system and business analysis should a programmer be reasonably expected to do?

    - by Rahul
    In most places I have worked for, there were no formal System or Business Analysts and the programmers were expected to perform both the roles. One had to understand all the subsystems and their interdependencies inside out. Further, one was also supposed to have a thorough knowledge of the business logic of the applications and interact directly with the users to gather requirements, answer their queries etc. In my current job, for ex, I spend about 70% time doing system analysis and only 30% time programming. I consider myself a good programmer but struggle with developing a good understanding of the business rules of a complex application. Often, this creates a handicap because while I can write efficient algorithms and thread-safe code, I lose out to guys who may be average programmers but have a much better understanding of the business processes. So I want to know - How much business and systems knowledge should a programmer have ? - How does one go about getting this knowledge in an immensely complex software system (e.g. trading applications) with several interdependent business processes but poorly documented business rules.

    Read the article

  • Limiting game loop to exactly 60 tics per second (Android / Java)

    - by user22241
    So I'm having terrible problems with stuttering sprites. My rendering and logic takes less than a game tic (16.6667ms) However, although my game loop runs most of the time at 60 ticks per second, it sometimes goes up to 61 - when this happens, the sprites stutter. Currently, my variables used are: //Game updates per second final int ticksPerSecond = 60; //Amount of time each update should take final int skipTicks = (1000 / ticksPerSecond); This is my current game loop @Override public void onDrawFrame(GL10 gl) { // TODO Auto-generated method stub //This method will run continuously //You should call both 'render' and 'update' methods from here //Set curTime initial value if '0' //Set/Re-set loop back to 0 to start counting again loops=0; while(System.currentTimeMillis() > nextGameTick && loops < maxFrameskip){ SceneManager.getInstance().getCurrentScene().updateLogic(); //Time correction to compensate for the missing .6667ms when using int values nextGameTick+=skipTicks; timeCorrection += (1000d/ticksPerSecond) % 1; nextGameTick+=timeCorrection; timeCorrection %=1; //Increase loops loops++; } render(); } I realise that my skipTicks is an int and therefore will come out as 16 rather that 16.6667 However, I tried changing it (and ticksPerSecond) to Longs but got the same problem). I also tried to change the timer used to Nanotime and skiptics to 1000000000/ticksPerSecond, but everything just ran at about 300 ticks per seconds. All I'm attempting to do is to limit my game loop to 60 - what is the best way to guarantee that my game updates never happen at more than 60 times a second? Please note, I do realise that very very old devices might not be able to handle 60 although I really don't expect this to happen - I've tested it on the lowest device I have and it easily achieves 60 tics. So I'm not worried about a device not being able to handle the 60 ticks per second, but rather need to limit it - any help would be appreciated.

    Read the article

  • Scrolling a WriteableBitmap

    - by Skoder
    I need to simulate my background scrolling but I want to avoid moving my actual image control. Instead, I'd like to use a WriteableBitmap and use a blitting method. What would be the way to simulate an image scrolling upwards? I've tried various things buy I can't seem to get my head around the logic: //X pos, Y pos, width, height Rect src = new Rect(0, scrollSpeed , 480, height); Rect dest = new Rect(0, 700 - scrollSpeed , 480, height); //destination rect, source WriteableBitmap, source Rect, blend mode wb.Blit(destRect, wbSource, srcRect, BlendMode.None); scrollSpeed += 5; if (scrollSpeed > 700) scrollSpeed = 0; If height is 10, the image is quite fuzzy and moreso if the height is 1. If the height is a taller, the image is clearer, but it only seems to do a one to one copy. How can I 'scroll' the image so that it looks like it's moving up in a continuous loop? (The height of the screen is 700).

    Read the article

  • Confused about implementing Single Responsibility Principle

    - by HichemSeeSharp
    Please bear with me if the question looks not well structured. To put you in the context of my issue: I am building an application that invoices vehicles stay duration in a parking. In addition to the stay service there are some other services. Each service has its own calculation logic. Here is an illustration (please correct me if the design is wrong): public abstract class Service { public int Id { get; set; } public bool IsActivated { get; set; } public string Name { get; set } public decimal Price { get; set; } } public class VehicleService : Service { //MTM : many to many public virtual ICollection<MTMVehicleService> Vehicles { get; set; } } public class StayService : VehicleService { } public class Vehicle { public int Id { get; set; } public string ChassisNumber { get; set; } public DateTime? EntryDate { get; set; } public DateTime? DeliveryDate { get; set; } //... public virtual ICollection<MTMVehicleService> Services{ get; set; } } Now, I am focusing on the stay service as an example: I would like to know at invoicing time which class(es) would be responsible for generating the invoice item for the service and for each vehicle? This should calculate the duration cost knowing that the duration could be invoiced partially so the like is as follows: not yet invoiced stay days * stay price per day. At this moment I have InvoiceItemsGenerator do everything but I am aware that there is a better design.

    Read the article

  • If and else condition not working properly in xna [closed]

    - by user1090751
    I am developing chess like game and i wanted to show error message if user try to place any player inside the box which is not empty. For example in certain place if there is empty then the object(2d object) is placed else it should show error message. However in my program it is showing message everytime i.e when i place object on empty place then also it is showing error message. Please see the below code: protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); // TODO: Add your update logic here for (int i = 0; i < 25; i++) { MouseState mouseState; mouseDiBack = false; mouseState = Mouse.GetState(); if (new Rectangle(mouseState.X, mouseState.Y, 1, 1).Intersects(rect_arr[i])) { background_color_arr[i] = Color.Red; } else { background_color_arr[i] = Color.White; } if (new Rectangle(mouseState.X, mouseState.Y, 1, 1).Intersects(rect_arr[i]) && (mouseState.LeftButton == ButtonState.Pressed)) { if (boxes[i] != "goat" && boxes[i] != "tiger") { place = i; if (turn == "goat") { boxes[i] = "goat"; turn = "tiger"; } else { boxes[i] = "tiger"; turn = "goat"; } } else { errMsg = "This " + i + " block is not empty to place " + turn + ". Please select empty block!!"; } } } base.Update(gameTime); }

    Read the article

  • How to Programmatically Split Data Using VBA Using Specific Logic

    - by Charlene
    This is an addition to my previous post here. The code that was previously supplied to me worked like a charm, but I am having issues modifying it adding some additional logic. I am creating a macro in VBA to do the following. I have raw order data that I need to transform based on some logic. Raw Data: order-id product-num date buyer-name prod-name qty-purc sales-tax freight order-st 0000000000-00 10000000000000 5/29/2014 John Doe Product 0 1 1.00 1.50 GA 0000000000-00 10000000000001 5/29/2014 John Doe Product 1 2 1.00 1.50 GA 0000000000-00 10000000000002 5/29/2014 John Doe Product 2 1 1.00 2.00 GA 0000000000-01 10000000000002 5/30/2014 Jane Doe Product 2 1 0.00 0.00 PA 0000000000-01 10000000000003 5/30/2014 Jane Doe Product 3 1 0.00 0.00 PA Desired Outcome: HDR 0000000000-00 John Doe 5/29/2014 CHG Tax 3.00 CHG Freight 5.00 ITM 10000000000000 Product 0 1 ITM 10000000000001 Product 1 2 ITM 10000000000002 Product 2 1 HDR 0000000000-01 Jane Doe 5/30/2014 ITM 10000000000002 Product 2 1 ITM 10000000000003 Product 3 1 The "CHG" rows are created based on the following logic; if the order-st is CA or GA, add the total of sales-tax and freight for each of the rows with the same order-id. If the order-st is NOT CA or GA, no CHG rows should be created. Any help would be appreciated - let me know if I left any details out!

    Read the article

  • Another word for Business Logic?

    - by herzmeister der welten
    What is another good word for Business Logic? Software might also run in civil service offices or for hobbyists, so I never felt that comfortable with using that term in certain modules and documentation. App Logic is too specific as well, because logic modules might also be used in services.

    Read the article

  • WCF Business logic handling

    - by Raj
    I have a WCF service that supports about 10 contracts, we have been supporting a client with all the business rules specific to this client now we have another client who will be using the exact same contracts (so we cannot change that) they will be calling the service exactly the same way the previous client called now the only way we can differentiate between the two clients is by one of the input parameters. Based on this input parameter we have to use a slightly different business logic – the logic for both the Client will be same 50% of the time the remainder will have different logic (across Business / DAL layers) . I don’t want to use if else statement in each of contract implementation to differentiate and reroute the logic also what if another client comes in. Is there a clean way of handling a situation like this. I am using framework 3.5. Like I said I cannot change any of the contracts (service / data contract ) or the current service calling infrastructure for the new client. Thanks

    Read the article

  • Business Layer Pattern on Rails? MVCL

    - by Fabiano PS
    That is a broad question, and I appreciate no short/dumb asnwers like: "Oh that is the model job, this quest is retarded (period)" PROBLEM Where I work at people created a system over 2 years for managing the manufacture process over demand in the most simplified still broad as possible, involving selling, buying, assemble, The system is coded over Ruby On Rails. The result has been changed lots of times and the result is a mess on callbacks (some are called several times), 200+ models, and fat controllers: Total bad. The QUESTION is, if there is a gem, or pattern designed to handle Rails large app logic? The logic whould be able to fully talk to models (whose only concern would be data format handling and validation) What I EXPECT is to reduce complexity from various controllers, and hard to track callbacks into files with the responsibility to handle a business operation logic. In some cases there is the need to wait for a response, in others, only validation of the input is enough and a bg process would take place. ie: -- Sell some products (need to wait the operation to finish) 1. Set a View able to get the products input 2. Controller gets the product list inputed by employee and call the logic Logic::ExecuteWithResponse('sell', 'products', :prods => @product_list_with_qtt, :when => @date, :employee => current_user() ) This Logic would handle buying order, assemble order, machine schedule, warehouse reservation, and others

    Read the article

  • Matching first set of elements with xpath...

    - by Ugo Enyioha
    I have an xml document that looks like this. <foo> <bar type="artist"/> Bob Marley </bar> <bar type="artist"/> Peter Tosh </bar> <bar type="artist"/> Marlon Wayans </bar> </foo> <foo> <bar type="artist"/> Bob Marley </bar> <bar type="artist"/> Peter Tosh </bar> <bar type="artist"/> Marlon Wayans </bar> </foo> <foo> <bar type="artist"/> Bob Marley </bar> <bar type="artist"/> Peter Tosh </bar> <bar type="artist"/> Marlon Wayans </bar> </foo> I would like to construct an xpath that returns only the first set: <bar type="artist"/> Bob Marley </a> <bar type="artist"/> Peter Tosh </a> <bar type="artist"/> Marlon Wayans </a> How would one go about this? I have tried //bar[@type='artist'] but it's obvious there's more to this. Thanks in advance.

    Read the article

  • Add game mechanics through equipment?

    - by Sidar
    In a game with different weapons and armor that actually affect more than just player stats, how would you achieve such effect? (These are just examples not concrete ideas ) For example we could have a handgun, uzi and then you have the graviton-gun. The first two would just shoot bullets, the third one does more than just shoot a simple projectile. It could allow the player to hold an enemy and drag it to use it as a meat shield. The player could also wear generic armor but at some point wears armor that can absorb projectiles. After absorbing enough projectiles you can shoot a giant blast. All these weapons/armor have different "behaviors" that either just raise stats or actually add new mechanics. In a simple case most guns would have similar properties and changing a few settings would create a new weapon (handgun shoots at an interval of x amount of seconds, lower this number and you have a machinegun). This obviously does not work if you intend to do more than just shoot projectiles. I'm pretty much stuck on writing the interface structure. While weapons and armor have different purposes they should both be able to process certain effects that change or add mechanics in the game world.

    Read the article

  • Architecture strategies for a complex competition scoring system

    - by mikewassmer
    Competition description: There are about 10 teams competing against each other over a 6-week period. Each team's total score (out of a 1000 total available points) is based on the total of its scores in about 25,000 different scoring elements. Most scoring elements are worth a small fraction of a point and there will about 10 X 25,000 = 250,000 total raw input data points. The points for some scoring elements are awarded at frequent regular time intervals during the competition. The points for other scoring elements are awarded at either irregular time intervals or at just one moment in time. There are about 20 different types of scoring elements. Each of the 20 types of scoring elements has a different set of inputs, a different algorithm for calculating the earned score from the raw inputs, and a different number of total available points. The simplest algorithms require one input and one simple calculation. The most complex algorithms consist of hundreds or thousands of raw inputs and a more complicated calculation. Some types of raw inputs are automatically generated. Other types of raw inputs are manually entered. All raw inputs are subject to possible manual retroactive adjustments by competition officials. Primary requirements: The scoring system UI for competitors and other competition followers will show current and historical total team scores, team standings, team scores by scoring element, raw input data (at several levels of aggregation, e.g. daily, weekly, etc.), and other metrics. There will be charts, tables, and other widgets for displaying historical raw data inputs and scores. There will be a quasi-real-time dashboard that will show current scores and raw data inputs. Aggregate scores should be updated/refreshed whenever new raw data inputs arrive or existing raw data inputs are adjusted. There will be a "scorekeeper UI" for manually entering new inputs, manually adjusting existing inputs, and manually adjusting calculated scores. Decisions: Should the scoring calculations be performed on the database layer (T-SQL/SQL Server, in my case) or on the application layer (C#/ASP.NET MVC, in my case)? What are some recommended approaches for calculating updated total team scores whenever new raw inputs arrives? Calculating each of the teams' total scores from scratch every time a new input arrives will probably slow the system to a crawl. I've considered some kind of "diff" approach, but that approach may pose problems for ad-hoc queries and some aggegates. I'm trying draw some sports analogies, but it's tough because most games consist of no more than 20 or 30 scoring elements per game (I'm thinking of a high-scoring baseball game; football and soccer have fewer scoring events per game). Perhaps a financial balance sheet analogy makes more sense because financial "bottom line" calcs may be calculated from 250,000 or more transactions. Should I be making heavy use of caching for this application? Are there any obvious approaches or similar case studies that I may be overlooking?

    Read the article

  • Derive a algorithm to match best position

    - by Farooq Arshed
    I have pieces in my game which have stats and cost assigned to them and they can only be placed at a certain location. Lets say I have 50 pieces. e.g. Piece1 = 100 stats, 10 cost, Position A. Piece2 = 120 stats, 5 cost, Position B. Piece3 = 500 stats, 50 cost, Position C. Piece4 = 200 stats, 25 cost, Position A. and so on.. I have a board on which 12 pieces have to be allocated and have to remain inside the board cost. e.g. A board has A,B,C ... J,K,L positions and X Cost assigned to it. I have to figure out a way to place best possible piece in the correct position and should remain within the cost specified by the board. Any help would be appreciated.

    Read the article

  • Issuse with multiple student result printing request

    - by dotman14
    I'm not really sure about how to ask this question but i'll try my best to make it clear enough. I have a Student Result Application where by students result are managed, over several academic sessions, all having two semesters each. During each semester students take different courses and have results based on the semester. The application is done now and i'm using a PDF Libaray to crop the final result page to hand over to the students each semester. If a student request a particular semester result it's a straight forward issue and there are no complications when it comes to printing out the result. My issue is this: in a case where a student requests to have a combination of semesters...say 3rd year rain semester , 4th year rain semester and 5th year hamattarn semester. Please how can i handle this issue? Does the user picks these options at the user interface level or there's a special way to handle issues like this? Also, if i'm to display these multiple student result how could this be be done, knowing fully well that i'll have to print the different result seperately. Hopefully i've being able to make my situation clear enough. Thanks for your time and patience. Expecting your comments and answers. Thanks.

    Read the article

  • Should "closed as duplicate" software programming be extreme or functional? [migrated]

    - by Web Developer
    I'm a web developer loving this site for it's potential, and it's Coffee look . I was reading a great question, that is this: click here and noticed 8 moderators tagged it as DUPLICATED! The question was closed! Obviously it isn't and I'm going to explain why if needed but it can be seen: the question is unique, is the case/story of a young who have SPECIFIC experience with C++ , VB and Assembler and asking, knowing this specifications an answer (It is not a general question like "hey I'm young can I do the programmer??") Let me know your opinion! do you think this question should or should not be closed? And let's think about also the people not only the "data" and "cases covered" ... do you think this is important too? or is better to keep a place where people doesn't count?

    Read the article

  • Teaching logical/analytical thinking

    - by Joshua
    I have been trial running a club in which I teach programming for the past year and while they have progressed what they really lack is the most fundamental concept to programming, analytical thinking. As I now approach the second year of teaching to the children (aged 12 - 14) I am now realising that before I begin teaching them the syntax and how to actually program an app (or what they would rather, a game) I need to introduce them to analytical thinking first. I have already found Scratch and similar things such as Light-Bot and will most certainly be using the, to teach them how to implement their logical thinking but what I really need are some tips or articles on how to teach analytical thinking itself to children aged 12 - 14. What I'm looking for are some ideas on how to teach the kind of thinking that these kids will need in order to get them into programming, whether that be analytical, logical or critical. How and what should I teach them relating to the way their minds need to be wired when programming solutions to problems?

    Read the article

  • Is "code that generates code" really all that great?

    - by Jaxo
    I was looking through CodePen's "popular pens" and I noticed this cool little spiral animation somebody made with a seemingly ridiculously small amount of code. This is quite impressive until you click the headings for HTML and CSS to show the "compiled" versions of the same code. Suddenly the 3 lines of HAML and ~40 lines of SCSS turns into a gigantic monster of repetition. Here's where my question comes in: Is it acceptable to do something like this in practice? Don't get me wrong - I love using preprocessors to help me write code faster, but in some cases it looks like it's an automatic copy-paste machine.

    Read the article

  • Get Your Logical Fallacies Straight with this Rhetological Fallacies Chart

    - by Jason Fitzpatrick
    Have trouble telling your Ad Hocs from your Ad Hominems? Fear not, this extensive and easy to read logical fallacy chart makes it easy to tell when someone is begging the question or suffering from a confirmation bias. Rhetological Fallacies Chart [via Neatorama] How to Own Your Own Website (Even If You Can’t Build One) Pt 2 How to Own Your Own Website (Even If You Can’t Build One) Pt 1 What’s the Difference Between Sleep and Hibernate in Windows?

    Read the article

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