Daily Archives

Articles indexed Wednesday February 23 2011

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

  • Recommended requirements when outsourcing xhtml/css site building?

    - by András Szepesházi
    I'm considering outsourcing a part of our web application development project for freelancers, namely the site building part. What I mean by site building is the process of creating the xhtml/css template files, with dummy content, from a psd file (or any other graphical layout file). The resulting xhtml/css files will be used by our developers as templates for cms based page rendering. The cms in this case is Drupal, but that might not be of much relevance. I'm looking for a good set of requirements, that will result in good quality xhtml/css code, complying with today's standards leaves little to the freelancer developer's imagination in terms of what I need I'm thinking about requirements like: Valid XHTML 1.0 Transitional document type, validated by validator.w3.org Identical rendering in all modern browsers (FF, Chrome, Safari, Opera, IE7-8) and also in IE6 All opening and closing block-level elements should be properly commented, referencing the functional part of the user interface they belong to (menu, toolbar, content, etc) No inline CSS definitions And so on. How would you organize a list like that? What requirements would you add?

    Read the article

  • C# Dev - I've tried Lisps, but I don't get it.

    - by Jonathan Mitchem
    After a few months of learning about and playing with lisps, both CL and a bit of Clojure, I'm still not seeing a compelling reason to write anything in it instead of C#. I would really like some compelling reasons, or for someone to point out that I'm missing something really big. The strengths of a Lisp (per my research): Compact, expressive notation - More so than C#, yes... but I seem to be able to express those ideas in C# too. Implicit support for functional programming - C# with LINQ extension methods: mapcar = .Select( lambda ) mapcan = .Select( lambda ).Aggregate( (a,b) = a.Union(b) ) car/first = .First() cdr/rest = .Skip(1) .... etc. Lambda and higher-order function support - C# has this, and the syntax is arguably simpler: "(lambda (x) ( body ))" versus "x = ( body )" "#(" with "%", "%1", "%2" is nice in Clojure Method dispatch separated from the objects - C# has this through extension methods Multimethod dispatch - C# does not have this natively, but I could implement it as a function call in a few hours Code is Data (and Macros) - Maybe I haven't "gotten" macros, but I haven't seen a single example where the idea of a macro couldn't be implemented as a function; it doesn't change the "language", but I'm not sure that's a strength DSLs - Can only do it through function composition... but it works Untyped "exploratory" programming - for structs/classes, C#'s autoproperties and "object" work quite well, and you can easily escalate into stronger typing as you go along Runs on non-Windows hardware - Yeah, so? Outside of college, I've only known one person who doesn't run Windows at home, or at least a VM of Windows on *nix/Mac. (Then again, maybe this is more important than I thought and I've just been brainwashed...) The REPL for bottom-up design - Ok, I admit this is really really nice, and I miss it in C#. Things I'm missing in a Lisp (due to a mix of C#, .NET, Visual Studio, Resharper): Namespaces. Even with static methods, I like to tie them to a "class" to categorize their context (Clojure seems to have this, CL doesn't seem to.) Great compile and design-time support the type system allows me to determine "correctness" of the datastructures I pass around anything misspelled is underlined realtime; I don't have to wait until runtime to know code improvements (such as using an FP approach instead of an imperative one) are autosuggested GUI development tools: WinForms and WPF (I know Clojure has access to the Java GUI libraries, but they're entirely foreign to me.) GUI Debugging tools: breakpoints, step-in, step-over, value inspectors (text, xml, custom), watches, debug-by-thread, conditional breakpoints, call-stack window with the ability to jump to the code at any level in the stack (To be fair, my stint with Emacs+Slime seemed to provide some of this, but I'm partial to the VS GUI-driven approach) I really like the hype surrounding Lisps and I gave it a chance. But is there anything I can do in a Lisp that I can't do as well in C#? It might be a bit more verbose in C#, but I also have autocomplete. What am I missing? Why should I use Clojure/CL?

    Read the article

  • Are there any "best practices" on cross-device development?

    - by vstrien
    Developing for smartphones in the way the industry is currently doing is relatively new. Of course, there has been enterprise-level mobile development for several decades. The platforms have changed, however. Think of: from stylus-input to touch-input (different screen res, different control layout etc.) new ways of handling multi-tasking on mobile platforms (e.g. WP7's "tombstoning") The way these platforms work aren't totally new (iPhone has been around for quite awhile now for example), but at the moment when developing a functionally equal application for both desktop and smartphone it comes down to developing two applications from ground up. Especially with the birth of Windows Phone with the .NET-platform on board and using Silverlight as UI-language, it's becoming appealing to promote the re-use of (parts of the UI). Still, it's fairly obvious that the needs of an application on a smartphone (or tablet) are very different compared to the needs of a desktop application. An (almost) one-on-one conversion will therefore be impossible. My question: are there "best practices", pitfalls etc. documented about developing "cross-device" applications (for example, developing an app for both the desktop and the smartphone/tablet)? I've been looking at weblogs, scientific papers and more for a week or so, but what I've found so far is only about "migratory interfaces".

    Read the article

  • How do open-source projects grow?

    - by dan_waterworth
    I know of lots of software that is open-source. For at least some of it, someone, somewhere must have written the first version alone. How does good open-source software become well known? I'm most interested in the first steps. How does software written by one person gain its first new contributors? I'm looking for practical advise. I've started a project here, called aodbm. What steps can I take to give it the best possible start?

    Read the article

  • All command need privilage

    - by Am1rr3zA
    I try to install Hping3 in my ubuntu 8.04 but after installation when I want to Hping3 I got this error: Command 'hping3' is available in '/usr/sbin/hping3' The command could not be located because '/usr/sbin' is not included in the PATH environment variable. This is most likely caused by the lack of administrative priviledges associated with your user account. also when I try to run ifconfig I get this: Command 'ifconfig' is available in '/sbin/ifconfig' The command could not be located because '/sbin' is not included in the PATH environment variable. This is most likely caused by the lack of administrative priviledges associated with your user account. first it needs to run sudo su and then run the command. is it normal? or I miss something? when I run echo $PATH I get: /usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/home/amirreza/simulator/ns-allinone-2.33/bin:/home/amirreza/simulator/ns-allinone-2.33/tcl8.4.18/unix:/home/amirreza/simulator/ns-allinone-2.33/tk8.4.18/unix:/home/amirreza/simulator/ns-allinone-2.33/ns-2.33/:/home/amirreza/simulator/ns-allinone-2.33/nam-1.14/

    Read the article

  • Slow wifi with D-link DWA-160 A2

    - by Tommy Brunn
    I recently bought a USB wifi adapter for my new desktop computer. It's a D-link DWA-160 A2. From the start it didn't want to work at all, but after unplugging and then plugging it back in, it seems to work. However, my browsing is painfully slow. NetworkManager reports the connection to be at around 78-85% signal strength, which seems perfectly acceptable. Is there anything I can do to make it faster? I'm dual booting with Windows 7, where it seems to work fine, so I'm guessing that the problem occurs because of crappy drivers.

    Read the article

  • Why UFW has to be (re)started at boot time if it's only iptables rule manager?

    - by Tomasz Zielinski
    README from source package says: When installing ufw from source, you will also need to integrate it into your boot process for the firewall to start when you restart your system. Depending on your needs, this can be as simple as adding the following to a startup script (eg rc.local for systems that use it): # /lib/ufw/ufw-init start For systems that use SysV initscripts, an example script is provided in doc/initscript.example. See doc/upstart.example for an Upstart example. Consult your distribution's documentation for the proper way to modify your boot process. On my system I have this: # /etc/ufw/ufw.conf # # Set to yes to start on boot. If setting this remotely, be sure to add a rule # to allow your remote connection before starting ufw. Eg: 'ufw allow 22/tcp' ENABLED=yes So, why does simple iptables rule manager need to be started at boot time? Is there any secret to that, or it merely checks if all rules are in place ?

    Read the article

  • Delete U3 System from SanDisk Cruzer USB Drive [closed]

    - by Petriborg
    Possible Duplicate: How do I get rid of “U3 System” on my USB drive? SanDisk Cruzer come with a "U3" malware built into them. Its intended for windows, but on Ubuntu it shows up as a "U3 System" CD on the desktop and as /dev/scd1 -> sr1 My question - How do I permanently delete this from the device without windows? I'm aware of the windows program, but I don't have access to any, and in any event, I wouldn't want to insert the stick into a windows box because it automatically installs its malware to any windows box comes into contact with! A friend of mine realized you could delete the cdrom via sudo echo "1" > /sys/class/block/srXXX/device/delete But it will come back if you reboot.

    Read the article

  • create a .deb Package from scripts or binaries

    - by tdeutsch
    I searched for a simple way to create .deb Packages for things which have no source code to compile (configs, shellscripts, proprietary software). This was quite a problem because most of the package tutorials are assuming you have a source tarball you want to compile. Then I've found this short tutorial (german). Afterwards, I created a small script to create a simple repository. Like this: rm /export/my-repository/repository/* cd /home/tdeutsch/deb-pkg for i in $(ls | grep my); do dpkg -b ./$i /export/my-repository/repository/$i.deb; done cd /export/avanon-repository/repository gpg --armor --export "My Package Signing Key" > PublicKey apt-ftparchive packages ./ | gzip > Packages.gz apt-ftparchive packages ./ > Packages apt-ftparchive release ./ > /tmp/Release.tmp; mv /tmp/Release.tmp Release gpg --output Release.gpg -ba Release I added the key to the apt keyring and included the source like this: deb http://my.default.com/my-repository/ ./ It looks like the repo itself is working well (I ran into some problems, to fix them I needed to add the Packages twice and make the temp-file workaround for the Release file). I also put some downloaded .deb into the repo, it looks like they are also working without problems. But my self created packages didn't... Wenn i do sudo apt-get update, they are causing errors like this: E: Problem parsing dependency Depends E: Error occurred while processing my-printerconf (NewVersion2) E: Problem with MergeList /var/lib/apt/lists/my.default.com_my-repository_._Packages E: The package lists or status file could not be parsed or opened. Has anyone an idea what I did wrong?

    Read the article

  • Dell Inspiron 1120 Ubuntu Light -> Desktop and now I'm having problems with wifi and suspend

    - by David N. Welton
    I got a Dell Inspiron 1120 which ships with Ubuntu Light, as well as Windows. My wife prefers Ubuntu, but obviously outside of web stuff, you can't do a lot with Light, so I went ahead and installed the Desktop version of Ubuntu (10.10 / maverick). Whereas before it suspended beautifully and connected to wifi networks flawlessly, it now displays the following problems: It seems to suspend ok, but on resume, the screen remains blank, even though the computer appears to wake up again. Wifi doesn't connect. I tried using the suggested proprietary drivers, and those don't seem to change the situation. All in all, a bit frustrating to run into these sorts of "regressions" - does anyone know what sort of drivers and such Ubuntu Light might have shipped with for this computer that made it work so well? Unfortunately, I wiped the disk in order to install the Desktop version of Ubuntu.

    Read the article

  • Is there a good [and modern] reason to not have static HTML pages with AJAX content , rather than generate pages?

    - by user1725
    Assumptions: We don't care about IE6, and Noscript users. Lets pretend we have the following design concept: All your pages are HTML/CSS that create the ascetics, layout, colours, general design related things. Lets pretend this basic code below is that: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <link href="/example.css" rel="stylesheet" type="text/css"/> <script src="example.js" type="text/javascript"></script> <head> <body> <div class="left"> </div> <div class="mid"> </div> <div class="right"> </div> </body> </html> Which in theory should produce, with the right CSS, three vertical columns on the web page. Now, here's the root of the question, what are the serious advantages and/or disadvantages of loading the content of these columns (lets assume they are all indeed dynamic content, not static) via AJAX requests, or have the content pre-set with a scripting language? So for instance, we would have, in the AJAX example, lets asume jquery is used on-load: //Multiple http requests $("body > div.left").load("./script.php?content=news"); $("body > div.right").load("./script.php?content=blogs"); $("body > div.mid").load("./script.php?content=links"); OR--- //Single http request $.ajax({ url: './script.php?content=news|blogs|links', method: 'json', type: 'text', success: function (data) { $("body > div.left").html(data.news); $("body > div.right").html(data.blogs); $("body > div.mid").html(data.links); } }) Verses doing this: <body> <div class="left"> <?php echo function_returning_news(); ?> </div> <div class="mid"> <?php echo function_returning_blogs(); ?> </div> <div class="right"> <?php echo function_returning_links(); ?> </div> </body> I'm personally thinking right now that doing static HTML pages is a better method, my reasoning is: I've separated my data, logic, and presentation (ie, "MVC") code. I can make changes to one without others. Browser caches mean I'm just getting server load mostly for the content, not the presentation wrapped around it. I could turn my "script.php" into a more robust API for the website. But I'm not certain or clear that these are legitimately good reasons, and I'm not confidently aware of other issues that could happen, so I would like to know the pros-and-cons, so to speak.

    Read the article

  • Apache httpd Problem

    - by Christopher
    Hey, I am getting intermittent issues with my site. Pages often hang with huge loading times and sometimes fail to load. The httpd error logs contain the following: [Wed Feb 23 06:54:17 2011] [debug] proxy_util.c(1854): proxy: grabbed scoreboard slot 0 in child 5871 for worker proxy:reverse [Wed Feb 23 06:54:17 2011] [debug] proxy_util.c(1967): proxy: initialized single connection worker 0 in child 5871 for (*) [Wed Feb 23 06:54:24 2011] [debug] proxy_util.c(1854): proxy: grabbed scoreboard slot 0 in child 5872 for worker proxy:reverse [Wed Feb 23 06:54:24 2011] [debug] proxy_util.c(1873): proxy: worker proxy:reverse already initialized [Wed Feb 23 06:54:24 2011] [debug] proxy_util.c(1967): proxy: initialized single connection worker 0 in child 5872 for (*) [Wed Feb 23 06:59:15 2011] [debug] proxy_util.c(1854): proxy: grabbed scoreboard slot 0 in child 5954 for worker proxy:reverse [Wed Feb 23 06:59:15 2011] [debug] proxy_util.c(1873): proxy: worker proxy:reverse already initialized The server is currently running with 800mb free memory, so it is not caused by lack of RAM. Any suggestions would be greatly appreciated. Many thanks, Chris. EDIT The current number of httpd procceses is 11. This does increase as the error persists and can rise up to 25+. I am running Apache/2.2.3 (CentOS).

    Read the article

  • SEO Expert Question

    - by CheatSEO
    I have worked with a website in the past freedomist.com This site gathers wordpress articles from multiple news source sites, and then republishes them. The company that runs this site has about 50 other sites that do the same thing. They post links to sites such as twitter and secondary wordpress sites. Is this a moral way of increasing page ranking? Is this against the terms of service with lets say Google?

    Read the article

  • Consolidating multiple domain names

    - by Mike
    I have a client that has three separately hosted copies of their website, each on a separate domain name. The websites are all essentially the same, bar a few discrepancies caused by badly managed updates in the past. I will soon be launching a completely new website for them, at which point, all three domain names are to resolve to the same web server. One domain name will become the default domain name that they refer to in all their literature, and the other two will simply be used as catch-alls for old links, bookmarks, and so on. I would like to know what people consider the best route to achieve this. My plan so far is: Get the new site up and running on the new webserver. Change the relevant A record of the default domain name to point to the new webserver. a) Keep the existing hosting accounts in operation. Create a list of 301 redirects from old page names on the old site to new page names on the new site. or b) Configure CNAME records for the non-default domain names, each pointing to the new webserver. Create a list of 301 redirects on the new site that redirect from old page names to new page names. If my understanding is correct, 3a will help to maintain whatever search engine rankings the sites already have (I know it's not going to be perfect), while at the same time informing search engines that the old domain names are no longer in use. What's a good approach to take here?

    Read the article

  • Which Document Requires A Single Uri For Web Resources?

    - by Pietro Speroni
    I know that giving short, clear URI that do not change with time is considered good manners, but I need to create a system that is designed not to have them. But to do this I need to go back and find the document in which first it was explained that there should be a single URI per resource. And that it should not change with time. It is probably a document from T.B.L. or from the w3c. Anyone knows which document would that be? Thanks

    Read the article

  • PHPForm mail help [closed]

    - by tom
    I have a PHP Form with two different fieldsets and about 4 labels within each. The form mailer is one i found on a tutorial but I'm not sure how to set in all the variables. Should all the 'label for' names also be the name of the variable? And is it easy to format with font-size etc.. once its been sent to an email for easy reading? $course_title = $_POST['course_title']; $course_date = $_POST['course_date']; $course_code = $_POST['course_code']; $course_fee = $_POST['course_fee']; Say i have - Personal Details labels with - first_name, address, postcode, dob. Course Details labels with - course_title, course_date, course_code Would this be correct and if not would anyone be able to help me out here.

    Read the article

  • Which CMS can I use for my project?

    - by Nicolás A.
    I have to build a new website for my client.. and he needs this stuff: A user generated content website.. where users can upload their own videos.. (i will use a video hosting platform with api like fliqz.com) I must manage a big user system.. where users can create their own "sub-users"... the site must manage paid subscriptions and payments through paypal.. and other payment gateways... So the question is.. i have to use a pre-built CMS and extend it.. or just a good framework? I've been thinking about joomla, drupal and expressionengine... It's not neccesary to use a open source cms... I've looking at drupal.. but is not as easy to understand and extend... Can anyone help me to make a good decision?

    Read the article

  • Making a language switch main menu button in Drupal

    - by Let_Me_Be
    I have a bilingual site in Drupal. The problem is that I hate the language switch block taking up so much space (sometimes the only thing in the sidebar is the language switch block). So what I would love to have is language switch menu item, that would point to the other language (other then the current one). Something like this: | Home | Projects | BlaBla | | Cesky | after swith: | Domu | Projekty | Blabla | | English | Is that possible without writing a whole new module?

    Read the article

  • How to implement behavior in a component-based game architecture?

    - by ghostonline
    I am starting to implement player and enemy AI in a game, but I am confused about how to best implement this in a component-based game architecture. Say I have a following player character that can be stationary, running and swinging a sword. A player can transit to the swing sword state from both the stationary and running state, but then the swing must be completed before the player can resume standing or running around. During the swing, the player cannot walk around. As I see it, I have two implementation approaches: Create a single AI-component containing all player logic (either decoupled from the actual component or embedded as a PlayerAIComponent). I can easily how to enforce the state restrictions without creating coupling between individual components making up the player entity. However, the AI-component cannot be broken up. If I have, for example, an enemy that can only stand and walk around or only walks around and occasionally swing a sword, I have to create new AI-components. Break the behavior up in components, each identifying a specific state. I then get a StandComponent, WalkComponent and SwingComponent. To enforce the transition rules, I have to couple each component. SwingComponent must disable StandComponent and WalkComponent for the duration of the swing. When I have an enemy that only stands around, swinging a sword occasionally, I have to make sure SwingComponent only disables WalkComponent if it is present. Although this allows for better mix-and-matching components, it can lead to a maintainability nightmare as each time a dependency is added, the existing components must be updated to play nicely with the new requirements the dependency places on the character. The ideal situation would be that a designer can build new enemies/players by dragging components into a container, without having to touch a single line of engine or script code. Although I am not sure script coding can be avoided, I want to keep it as simple as possible. Summing it all up: Should I lob all AI logic into one component or break up each logic state into separate components to create entity variants more easily?

    Read the article

  • Install Domain Controller – Part1 of build my own development SharePoint2010 Farm

    - by ybbest
    As the memory become really cheap now, a couple days ago I have updated my laptop memory to 12g. Plus I got my old desktop ,now I decide to build my own SharePoint farm at home. I decide to document the steps to build a simple SharePoint farm. I will use windows server 2008 r2 and VMware. In the first part of this series of building my own SharePoint farm. I will create my domain controller. Here are the steps to install it: Open the command line by going to run and type CMD and then type dcpromo in the command line. The AD Installation wizard will prompt and click next. 2. Click next as shown in the screenshot.   3. Select creates a new domain in a new forest and click next.      4. Type a domain name (e.g. ybbest.com) and click next. 5.In my case , I select Windows Server 2008 R2 forest Functional level and click next 6. Leave the default and click next.(If you have not make a static IP address , you need to do so now)      7.You might get scary prompt like the screenshot below , just ignore the message and click Yes.     8.Leave the default settings and click Next  9.Type a password when you need to restore your Domain        10.Click Next and restart your computer ,this will install your Domain Controller.

    Read the article

  • Retrieve KEYWORDS from META tag in a HTML WebPage using JAVA.

    - by kooldave98
    Hello all, I want to retrieve all the content words from a HTML WebPage and all the keywords contained in the META TAG of the same HTML webpage using Java. For example, consider this html source code: <html> <head> <meta name = "keywords" content = "deception, intricacy, treachery"> </head> <body> My very short html document. <br> It has just 2 'lines'. </body> </html> The CONTENT WORDS here are: my, very, short, html, document, it, has, just, lines Note: The punctuation and the number '2' are ruled out. The KEYWORDS here are: deception, intricacy, treachery I have created a class for this purpose called WebDoc, this is as far as I have been able to get. import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import java.util.Set; import java.util.TreeSet; public class WebDoc { protected URL _url; protected Set<String> _contentWords; protected Set<String> _keyWords public WebDoc(URL paramURL) { _url = paramURL; } public Set<String> getContents() throws IOException { //URL url = new URL(url); Set<String> contentWords = new TreeSet<String>(); BufferedReader in = new BufferedReader(new InputStreamReader(_url.openStream())); String inputLine; while ((inputLine = in.readLine()) != null) { // Process each line. contentWords.add(RemoveTag(inputLine)); //System.out.println(RemoveTag(inputLine)); } in.close(); System.out.println(contentWords); _contentWords = contentWords; return contentWords; } public String RemoveTag(String html) { html = html.replaceAll("\\<.*?>",""); html = html.replaceAll("&",""); return html; } public Set<String> getKeywords() { //NO IDEA ! return null; } public URL getURL() { return _url; } @Override public String toString() { return null; } }

    Read the article

  • Visual ++ print from main with inheritance on visual form in listbox

    - by captencrunch
    I´ve made a "main" class lets call it A(Veichle), and i have two classes that inherits from A Lets call them B(Car) and C(MC). i also have a handler lets call it "D" that binds A,B and C. Then i have the Form1 class lets call that E(Visual) I want to print out the private members from A on the visual form "E" in a Listbox If i try ex) this-listbox1-items-add(X.veichles[i]-getBrand()); it complains that veichles is a private member in D. How can i get around that?

    Read the article

  • How to compare 2 complex spreadsheets running in parallel for consistency with each other?

    - by tbone
    I am working on converting a large number of spreadsheets to use a new 3rd party data access library (converting from third party library #1 to third party library #2). fyi: a call to a UDF (user defined function) is placed in a cell, and when that is refreshed, it pulls the data into a pivot table below the formula. Both libraries behave the same and produce the same output, except, small irregularites can arise, such as an additional field being shown in the output pivot table using library #2, which can affect formulas on the sheet if data is being read from the pivot table without using GetPivotData. So I have ~100 of these very complicated (20+ worksheets per workbook) spreadsheets that I have to convert, and run in parallel for a period of time, to see if the output using the new data access library matches the old library. Is there some clever approach to do this, so I don't have to spend a large amount of time analyzing each sheet to determine the specific elements to compare? Two rough ideas that come to mind: 1. just create a Validator workbook that has the same # of worksheets, and simply do a Worbook1!Worksheet1!A1 - Worbook2!Worksheet3!A1 for every possible cell on each sheet 2. roughly the equivalent of #1, but just traverse the cells in the 2 books using VBA, and log any cells that do not match. I don't particularly like either idea, can anyone think of something better than this, maybe some 3rd party utility I could buy?

    Read the article

  • .htaccess newb - RewriteRule not matching 2nd rule, why?

    - by jyoseph
    I am currently migrating from isapi_rewrite to .htaccess. I'm having some difficulty and I think it's something basic, but I'm not terribly familiar with .htaccess. I have the two rules like so: RewriteRule ^testing/ /test/index.html?test=1 [NC] RewriteRule ^testing/foo-bar/ /test/index.html?test=2 [NC] Yet the second rule never matches. If I go to http://mydomain.com/testing/foo-bar/ then I will only see the first rule. Why is that? And can it be easily fixed? I have many rules (outputted from the database to write the .htaccess file )and ordering them in a particular order isn't really possible.

    Read the article

  • How can i optimize this recursive method

    - by Tirdyr
    Hi there. I'm trying to make a word puzzle game, and for that i'm using a recursive method to find all possible words in the given letters. The letters is in a 4x4 board. Like this: ABCD EFGH HIJK LMNO The recursive method is called inside this loop: for (int y = 0; y < width; y++) { for (int x = 0; x < height; x++) { myScabble.Search(letters, y, x, width, height, "", covered, t); } } letters is a 2D array of chars. y & x is ints that shows where in the board width & height is also int, that tells the dimensions of the board "" is the string we are trying to make (the word) covered is an array of bools, to check if we allready used that square. t is a List (wich contains all the words to check against). The recursive method that need optimizing: public void Search(char[,] letters, int y, int x, int width, int height, string build, bool[,] covered, List<aWord> tt) { // Dont get outside the bounds if (y >= width || y < 0 || x >= height || x < 0) { return; } // Dont deal with allrady covered squares if (covered[x, y]) { return; } // Get Letter char letter = letters[x, y]; // Append string pass = build + letter; // check if its a possibel word //List<aWord> t = myWords.aWord.Where(w => w.word.StartsWith(pass)).ToList(); List<aWord> t = tt.Where(w => w.word.StartsWith(pass)).ToList(); // check if the list is emphty if (t.Count < 10 && t.Count != 0) { //stop point } if (t.Count == 0) { return; } // Check if its a complete word. if (t[0].word == pass) { //check if its allrdy present in the _found dictinary if (!_found.ContainsKey(pass)) { //if not add the word to the dictionary _found.Add(pass, true); } } // Check to see if there is more than 1 more that matches string pass // ie. are there more words to find. if (t.Count > 1) { // make a copy of the covered array bool[,] cov = new bool[height, width]; for (int i = 0; i < width; i++) { for (int a = 0; a < height; a++) { cov[a, i] = covered[a, i]; } } // Set the current square as covered. cov[x, y] = true; // Continue in all 8 directions. Search(letters, y + 1, x, width, height, pass, cov, t); Search(letters, y, x + 1, width, height, pass, cov, t); Search(letters, y + 1, x + 1, width, height, pass, cov, t); Search(letters, y - 1, x, width, height, pass, cov, t); Search(letters, y, x - 1, width, height, pass, cov, t); Search(letters, y - 1, x - 1, width, height, pass, cov, t); Search(letters, y - 1, x + 1, width, height, pass, cov, t); Search(letters, y + 1, x - 1, width, height, pass, cov, t); } } The code works as i expected it to do, however it is very slow.. it takes about 2 mins to find the words. EDIT: i clarified that the letters array is 2D

    Read the article

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