Search Results

Search found 91 results on 4 pages for 'lukas knuth'.

Page 3/4 | < Previous Page | 1 2 3 4  | Next Page >

  • Java method keyword "final" and its use

    - by Lukas Eder
    When I create complex type hierarchies (several levels, several types per level), I like to use the final keyword on methods implementing some interface declaration. An example: interface Garble { int zork(); } interface Gnarf extends Garble { /** * This is the same as calling {@link #zblah(0)} */ int zblah(); int zblah(int defaultZblah); } And then abstract class AbstractGarble implements Garble { @Override public final int zork() { ... } } abstract class AbstractGnarf extends AbstractGarble implements Gnarf { // Here I absolutely want to fix the default behaviour of zblah // No Gnarf shouldn't be allowed to set 1 as the default, for instance @Override public final int zblah() { return zblah(0); } // This method is not implemented here, but in a subclass @Override public abstract int zblah(int defaultZblah); } I do this for several reasons: It helps me develop the type hierarchy. When I add a class to the hierarchy, it is very clear, what methods I have to implement, and what methods I may not override (in case I forgot the details about the hierarchy) I think overriding concrete stuff is bad according to design principles and patterns, such as the template method pattern. I don't want other developers or my users do it. So the final keyword works perfectly for me. My question is: Why is it used so rarely in the wild? Can you show me some examples / reasons where final (in a similar case to mine) would be very bad?

    Read the article

  • Threading cost - minimum execution time when threads would add speed

    - by Lukas
    I am working on a C# application that works with an array. It walks through it (meaning that at one time only a narrow part of the array is used). I am considering adding threads in it to make it perform faster (it runs on a dualcore computer). The problem is that I do not know if it would actually help, because threads cost something and this cost could easily be more than the parallel gain... So how do I determine if threading would help?

    Read the article

  • Segmentation fault on writing char to char* address

    - by Lukas Dojcak
    hi guys, i've got problem with my little C program. Maybe you could help me. char* shiftujVzorku(char* text, char* pattern, int offset){ char* pom = text; int size = 0; int index = 0; while(*(text + size) != '\0'){ size++; } while(*(pom + index) != '\0'){ if(overVzorku(pom + index, pattern)){ while(*pattern != '\0'){ //vyment *pom s *pom + offset if(pom + index + offset < text + size){ char x = *(pom + index + offset); char y = *(pom + index); int adresa = *(pom + index + offset); *(pom + index + offset) = y; <<<<<< SEGMENTATION FAULT *(pom + index) = x; //*pom = *pom - *(pom + offset); //*(pom + offset) = *(pom + offset) + *pom; //*pom = *(pom + offset) - *pom; } else{ *pom = *pom - *(pom + offset - size); *(pom + offset - size) = *(pom + offset - size) + *pom; *pom = *(pom + offset - size) - *pom; } pattern++; } break; } index++; } return text; } Isn't important what's the programm doing. Mayby there's lot of bugs. But, why do I get SEGMENTATION FAULT (for destination see code) at this line? I'm, trying to write some char value to memory space, with help of address "pom + offset + index". Thanks for everything helpful. :)

    Read the article

  • DataGrid: dynamic DataTemplate for dynamic DataGridTemplateColumn

    - by Lukas Cenovsky
    I want to show data in a datagrid where the data is a collection of public class Thing { public string Foo { get; set; } public string Bar { get; set; } public List<Candidate> Candidates { get; set; } } public class Candidate { public string FirstName { get; set; } public string LastName { get; set; } ... } where the number of candidates in Candidates list varies at runtime. Desired grid layout looks like this Foo | Bar | Candidate 1 | Candidate 2 | ... | Candidate N I'd like to have a DataTemplate for each Candidate as I plan changing it during runtime - user can choose what info about candidate is displayed in different columns (candidate is just an example, I have different object). That means I also want to change the column templates in runtime although this can be achieved by one big template and collapsing its parts. I know about two ways how to achieve my goals (both quite similar): Use AutoGeneratingColumn event and create Candidates columns Add Columns manually In both cases I need to load the DataTemplate from string with XamlReader. Before that I have to edit the string to change the binding to wanted Candidate. Is there a better way how to create a DataGrid with unknown number of DataGridTemplateColumn? Note: This question is based on dynamic datatemplate with valueconverter

    Read the article

  • platform independent and open source

    - by Lukas Schmelzeisen
    Hey, OK i want to start writing platform independent and open source code (mostly C++). What do i have to consider when doing so? Stop using IDEs and better use makefiles from now on? What do all the "professional" open source coders do (like the guys behind GNU) and what tools do they use? I'm special interested into developing shared libraries. How do you get the cross platform (so working as ".so" on Linux and as ".dll" on Windows)? I'm working on Windows so I'm not that much into all the Linux tools and words, are there good tools to get the same result on Windows as on ?Linux Thanks

    Read the article

  • How to catch this type of exceptions ?

    - by Lukas Šalkauskas
    I'm starting getting tired of this exception. Can't handle it, even so I'm using this: AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Still no success, Can anyone explain me, how I should handle it in a nice way. Or how to detect that it have fired this message and close the application, because I'm starting it automatically everytime it closes.

    Read the article

  • Load balancing and shedulling algorithms .NET

    - by Lukas Šalkauskas
    Hello there, so here is my problem: I have several different configuarion servers. I have different calculations (jobs), I can predict how long approx. each job will take to be caclulated. Also I have priorities. My question is how to keep all machines loaded 99-100% and shedule the jobs in the best way. Each machine can do several calculations at the time. Jobs are pushed to the machine. Central machine knows current load of each machine. Also I would like to to assign some king of machine learning here, because I will know statistics of each job (started, finished, cpu load etc.). How to distribute jobs(calculations) in the best possible way, also keep in mind priority. Any suggestions ? Ideas ? Algorithms ?

    Read the article

  • Best Practises - Increase Mood for Coding

    - by Lukas Šalkauskas
    I recently find my self stuck in state where I feel not very into code, I need some kind of inspiration, so sometimes I just review somebody's code, watch some kind of movie about coding or something like that, but not always I get what I need, if you know what I mean. How do you increase your mood for coding ?

    Read the article

  • .NET SerialPort.Read skipps bytes

    - by Lukas Rieger
    Solution Reading the data byte wise via "port.ReadByte" is too slow, the problem is inside the SerialPort class. i changed it to reading bigger chunks via "port.Read" and there are now no buffer overruns. although i found the solution myself, writing it down helped me and maybe someone else has the same problem and finds this via google... (how can i mark it as answered?) EDIT 2 by setting port.ReadBufferSize = 2000000; i can delay the problem for ~30 seconds. so it seems, .Net really is too slow... since my application is not that critical, i just set the buffer to 20MB, but i am still interested in the cause. EDIT i just tested something i had not thought of before (shame on me): port.ErrorReceived += (object self, SerialErrorReceivedEventArgs se_arg) => { Console.Write("| Error: {0} | ", System.Enum.GetName(se_arg.EventType.GetType(), se_arg.EventType)); }; and it seems that i have an overrun. Is the .Net implementation too slow for 500k or is there an error on my side? Original Question i built a very primitive oszilloscope (avr, which sends adc data over uart to an ftdi chip). On the pc side i have a WPF Programm that displays this data. The Protokoll is: two sync bytes (0xaffe) - 14 data bytes - two sync bytes - 14 data bytes - ... i use 16bit values, so inside the 14 data bytes are 7 channels (lsb first). I verified the uC Firmware with hTerm, and it does send and receive everything correct. But, if i try to read the data with C#, sometimes some bytes are lost. The oszilloscop programm is a mess, but i created a small sample application, which has the same symptoms. I added two extension methods to a) read one byte from the COM Port and ignore -1 (EOF) and b) wait for the sync pattern. The sample programm first syncs onto the data stream by waiting for (0xaffe) and then compares the received bytes with the expected values. the loop runs a few times until an assert failed message pops up. I could not find anything about lost bytes via google, any help would be appreciated. Code using System; using System.Collections.Generic; using System.Diagnostics; using System.IO.Ports; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SerialTest { public static class SerialPortExtensions { public static byte ReadByteSerial(this SerialPort port) { int i = 0; do { i = port.ReadByte(); } while (i < 0 || i > 0xff); return (byte)i; } public static void WaitForPattern_Ushort(this SerialPort port, ushort pattern) { byte hi = 0; byte lo = 0; do { lo = hi; hi = port.ReadByteSerial(); } while (!(hi == (pattern >> 8) && lo == (pattern & 0x00ff))); } } class Program { static void Main(string[] args) { //500000 8n1 SerialPort port = new SerialPort("COM3", 500000, Parity.None, 8, StopBits.One); port.Open(); port.DiscardInBuffer(); port.DiscardOutBuffer(); //Sync port.WaitForPattern_Ushort(0xaffe); byte hi = 0; byte lo = 0; int val; int n = 0; // Start Loop, the stream is already synced while (true) { //Read 7 16-bit values (=14 Bytes) for (int i = 0; i < 7; i++) { lo = port.ReadByteSerial(); hi = port.ReadByteSerial(); val = ((hi << 8) | lo); Debug.Assert(val != 0xaffe); } //Read two sync bytes lo = port.ReadByteSerial(); hi = port.ReadByteSerial(); val = ((hi << 8) | lo); Debug.Assert(val == 0xaffe); n++; } } } }

    Read the article

  • CodeIgniter Validation in Library does not accept callback.

    - by Lukas Oppermann
    Hey guys, my problem is the following: I am writing a login library. This library has a function _validation() and this uses the validation library to validate the data. With using normal validation methods it works just fine, but using a callback function just does not work. It is not called. I call it like this. $this->CI->form_validation->set_rules('user', 'Username', 'required|callback__check_user'); The functions name is _check_user and it uses the username _check_user($user). The function itself works fine and I can also call it in the class ($this-_check_user('username')) with a working result. I am guessing, there might be a problem because I am not workin in a controller so I have a CI instance $this-CI instead of just the original instance $this- Does anyone have a clue how to fix this? Thanks in advance.

    Read the article

  • Load balancing and scheduling algorithms.

    - by Lukas Šalkauskas
    Hello there, so here is my problem: I have several different configuarion servers. I have different calculations (jobs); I can predict how long approximately each job will take to be caclulated. Also, I have priorities. My question is how to keep all machines loaded 99-100% and schedule the jobs in the best way. Each machine can do several calculations at a time. Jobs are pushed to the machine. The central machine knows the current load of each machine. Also, I would like to to assign some kind of machine learning here, because I will know statistics of each job (started, finished, cpu load etc.). How can I distribute jobs (calculations) in the best possible way, keeping in mind the priorities? Any suggestions, ideas, or algorithms ? FYI: My platform .NET.

    Read the article

  • How can I easily keep consistent UI settings in C# Winform application?

    - by Lukas
    I have a lot of different UserControls and would like to maintain consistent UI settings (mainly colors and fonts). My first try was this: public class UISettings { //... public void SetupUserControl(ref UserControl ctrl) { ctrl.BackColor = this.BackColor; } } to be called in every control like this: settings.SetupUserControl(ref this); As this is read-only it cannot be passed by ref argument so this does not work. What are other options to keep consistent UI without manually changing properties for every item?

    Read the article

  • WPF application in a one window

    - by lukas
    I would like to make an application in a one window using XAML. It should be like a slideshow with next and back button. One idea is to make 4 panels and have just one enable at the time. Is there any other way to do this? Like dynamic loading of other XAML? is it the BackgroundWorker mandatory to use with WPF (hence is DirectX rendered there's almost no GUI lags) ?

    Read the article

  • Factorial function - design and test.

    - by lukas
    I'm trying to nail down some interview questions, so I stared with a simple one. Design the factorial function. This function is a leaf (no dependencies - easly testable), so I made it static inside the helper class. public static class MathHelper { public static int Factorial(int n) { Debug.Assert(n >= 0); if (n < 0) { throw new ArgumentException("n cannot be lower that 0"); } Debug.Assert(n <= 12); if (n > 12) { throw new OverflowException("Overflow occurs above 12 factorial"); } //by definition if (n == 0) { return 1; } int factorialOfN = 1; for (int i = 1; i <= n; ++i) { //checked //{ factorialOfN *= i; //} } return factorialOfN; } } Testing: [TestMethod] [ExpectedException(typeof(OverflowException))] public void Overflow() { int temp = FactorialHelper.MathHelper.Factorial(40); } [TestMethod] public void ZeroTest() { int factorialOfZero = FactorialHelper.MathHelper.Factorial(0); Assert.AreEqual(1, factorialOfZero); } [TestMethod] public void FactorialOf5() { int factOf5 = FactorialHelper.MathHelper.Factorial(5); Assert.AreEqual(120,factOf5); } [TestMethod] [ExpectedException(typeof(ArgumentException))] public void NegativeTest() { int factOfMinus5 = FactorialHelper.MathHelper.Factorial(-5); } I have a few questions: Is it correct? (I hope so ;) ) Does it throw right exceptions? Should I use checked context or this trick ( n 12 ) is ok? Is it better to use uint istead of checking for negative values? Future improving: Overload for long, decimal, BigInteger or maybe generic method? Thank you

    Read the article

  • git submodule pull and commit automatically on webserver

    - by Lukas Oppermann
    I have the following setup, I am working on a project project with the submodule submodule. Whenever I push changes to github it sends a post request to update.php on the server. This php file executes a git command. Without submodules I can just do a git pull and everything is fine but with submodules it is much more difficult. I have this at the moment, but it does not do what I want. I should git pull the repo and update and pull the latest version of each submodule. <?php echo `git submodule foreach 'git checkout master; git pull; git submodule update --init --recursive; git commit -m "updating"' && git pull && git submodule foreach 'git add -A .' && git commit -m "updating to latest version including submodules" 2>&1s`; EDIT// Okay, I got it half way done. <?php echo `git submodule foreach 'git checkout master; git pull; git submodule update --init --recursive; git commit -am "updating"; echo "updated"' && git pull && git commit -am "updating to latest version including submodules" && echo 'updated'`; The echo prevents the script to stop because of non-zero returned. It works 100% fine when I run it from the console using php update.php. When github initialized the file, or I run it from the browser it still does not work. Any ideas?

    Read the article

  • How to attend one off lectures? [closed]

    - by Senthil Kumaran
    Many times, we come across one-off lectures from famous Computer Scientists. Last year, I came across one by Ms. Barbara Liskov, but I could not go because the University Hall was bit far. Tomorrow, there is one by Dr. Knuth! Now the problem I am facing is, "I don't know much about the material he is going to talk", so I am not sure if I should plan and I fear it will be like going for a "temple". :) What is your advise and general strategy that you have followed whenever you wanted to attend a talk or lecture wherein, it may have been worthwhile if it were an introductory tutorial, but instead you were sitting in an advanced 1 hour lecture by a famous scientist.

    Read the article

  • better media player than vlc with a real library [closed]

    - by elluca
    hi i have been using VLC for years. but my library of movies is growing an i would like to have a better management of them. sure, i could use itunes for that. but i really hat quicktime. the UI is even worse than the one windows media player got. i looked at winamp, windows media player and songbird. but none has got a UI comparable to VLC. the most important feature: hotkeys. i want to be able to skip in a video using the mouse scroll wheel. do i have to code one myself? ;) thanks lukas

    Read the article

  • Oracle Developer Day, Romania, 2012

    - by Geertjan
    I'm on the way back from a great experience in Cluj, Romania: the Oracle Developer Day that was held here today. After the Oracle Developer Day in Warsaw, two days ago, I flew to Bucharest and then had to wait about 6 hours for the flight to Cluj. So I spent several of those hours in a taxi, with a very nice driver who showed me all over the place in Bucharest, such as the Palace of Parliament (according to Wikipedia, "the world's largest civilian building, most expensive administrative building, and heaviest building"): He also taught me a lot of Romanian. (My current phonetic-based vocabulary can be admired and/or ridiculed here.) Meeting Emilian Bold (third on the right below) from the NetBeans Dream Team was a definite highlight: The above shows the three speakers on the Java Track "preparing" for their sessions; me, Lukas Jungmann, and Emilian Bold. In Oracle's Gregor Rayman's keynote, this particular slide responded well to my NetBeans heart: The "Java Track" had sessions on Java EE 6, the NetBeans Platform, and Java Web Services, as well as "What's New in NetBeans IDE 7.1", where Emilian, shown in action below, outlined the NetBeans community, e.g., the NetBeans Dream Team and the NetBeans governance board. (But it was all in Romanian so I'm not really sure what was said exactly!) Finally, there was time to recover from the whole day, right before my trip back to Bucharest: All in all a great day! Looking forward to remaining in touch with the many people I met today.

    Read the article

  • creating a tag-based website and not using programming?

    - by monodial
    I want to create a tag-based website, and I need a tool that I could use (preferably without programming). It's a site where a user could pick tags on a certain item. All tags will be placed under a group that they are logically linked to (I will do that by hand). On the other end - a visitor could choose a tag, and then be redirected to a few items on which that tag was selected the most. Besides this, I need to set up a registration form (for the visitors who want to select tags on a desired item). stackoverflow.com may serve as an example of what I want to achieve. Functionally it is a quite similar approach. I am not sure if further detailing will bring me closer to getting a development advice, but nevertheless - following this template what I would be missing on is: ability to categorize the tags; and so they would fit in one page (overall i assume <200 tags) box where a user could enter a tag and it would be pending until a certain number of users enter such tag ability to limit the number of 'questions' that appear when a visitor chooses a tag - 'question' stands for an item to which users are selecting tags (displayed items would depend on the frequency the tag was assigned - say the top two items) Which software should I try / How should I go about it? Thank you. Lukas P.S. I have bought hosting account through GoDaddy.com. This is a first website that I am trying to build.

    Read the article

  • GOTO still considered harmful?

    - by Kyle Cronin
    Everyone is aware of Dijkstra's Letters to the editor: go to statement considered harmful (also here .html transcript and here .pdf) and there has been a formidable push since that time to eschew the goto statement whenever possible. While it's possible to use goto to produce unmaintainable, sprawling code, it nevertheless remains in modern programming languages. Even the advanced continuation control structure in Scheme can be described as a sophisticated goto. What circumstances warrant the use of goto? When is it best to avoid? As a followup question: C provides a pair of functions, setjmp and longjmp, that provide the ability to goto not just within the current stack frame but within any of the calling frames. Should these be considered as dangerous as goto? More dangerous? Dijkstra himself regretted that title, of which he was not responsible for. At the end of EWD1308 (also here .pdf) he wrote: Finally a short story for the record. In 1968, the Communications of the ACM published a text of mine under the title "The goto statement considered harmful", which in later years would be most frequently referenced, regrettably, however, often by authors who had seen no more of it than its title, which became a cornerstone of my fame by becoming a template: we would see all sorts of articles under the title "X considered harmful" for almost any X, including one titled "Dijkstra considered harmful". But what had happened? I had submitted a paper under the title "A case against the goto statement", which, in order to speed up its publication, the editor had changed into a "letter to the Editor", and in the process he had given it a new title of his own invention! The editor was Niklaus Wirth. A well thought out classic paper about this topic, to be matched to that of Dijkstra, is Structured Programming with go to Statements (also here .pdf), by Donald E. Knuth. Reading both helps to reestablish context and a non-dogmatic understanding of the subject. In this paper, Dijkstra's opinion on this case is reported and is even more strong: Donald E. Knuth: I believe that by presenting such a view I am not in fact disagreeing sharply with Dijkstra's ideas, since he recently wrote the following: "Please don't fall into the trap of believing that I am terribly dogmatical about [the go to statement]. I have the uncomfortable feeling that others are making a religion out of it, as if the conceptual problems of programming could be solved by a single trick, by a simple form of coding discipline!"

    Read the article

  • Algorithm for Text Wrapping Within a Shape

    - by devongovett
    I am looking for an algorithm to wrap text within a non-rectangular shape, preferably based on the Knuth and Plass algorithm. The hardest part of this is that the lines may have different heights due to differing font sizes in the text. The image below is an example of what the algorithm should be able to generate. Thanks for any help!

    Read the article

< Previous Page | 1 2 3 4  | Next Page >