Search Results

Search found 366 results on 15 pages for 'closure cowboy'.

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

  • What's special about currying or partial application?

    - by Vigneshwaran
    I've been reading articles on Functional programming everyday and been trying to apply some practices as much as possible. But I don't understand what is unique in currying or partial application. Take this Groovy code as an example: def mul = { a, b -> a * b } def tripler1 = mul.curry(3) def tripler2 = { mul(3, it) } I do not understand what is the difference between tripler1 and tripler2. Aren't they both the same? The 'currying' is supported in pure or partial functional languages like Groovy, Scala, Haskell etc. But I can do the same thing (left-curry, right-curry, n-curry or partial application) by simply creating another named or anonymous function or closure that will forward the parameters to the original function (like tripler2) in most languages (even C.) Am I missing something here? There are places where I can use currying and partial application in my Grails application but I am hesitating to do so because I'm asking myself "How's that different?" Please enlighten me.

    Read the article

  • What is the correct way to handle debug output in Java?

    - by Federico Zancan
    As my current Java projects grow bigger and bigger, I feel a likewise growing need to insert debug output in several points of my code. To enable or disable this feature appropriately, depending on the opening or closure of the test sessions, I usually put a private static final boolean DEBUG = false at the beginning of the classes my tests are inspecting, and trivially use it this way (for example): public MyClass { private static final boolean DEBUG = false; ... some code ... public void myMethod(String s) { if (DEBUG) { System.out.println(s); } } } and the like. But that doesn't bliss me out, because of course it works but there could be too many classes in which to set DEBUG to true, if you are not staring at just a couple of them. Conversely, I (like - I think - many others) wouldn't love to put the whole application in debug mode, as the amount of text being output could be overwhelming. So, is there a correct way to architecturally handle such situation or the most correct way is to use the DEBUG class member?

    Read the article

  • Working with fubar/refuctored code

    - by Keyo
    I'm working with some code which was written by a contractor who left a year ago leaving a number of projects with buggy, disgustingly bad code. This is what I call cowboy PHP, say no more. Ideally I'd like to leave the project as is and never touch it again. Things break, requirements change and it needs to be maintained. Part A needs to be changed. There is a bug I cannot reproduce. Part A is connect to parts B D and E. This kind of work gives me a headache and makes me die a little inside. It kills my motivation and productivity. To be honest I'd say it's affecting my mental health. Perhaps being at the start of my career I'm being naive to think production code should be reasonably clean. I would like to hear from anyone else who has been in this situation before. What did you do to get out of it? I'm thinking long term I might have to find another job. Edit I've moved on from this company now, to a place where idiots are not employed. The code isn't perfect but it's at least manageable and peer reviewed. There are a lot of people in the comments below telling me that software is messy like this. Sure I don't agree with the way some programmers do things but this code was seriously mangled. The guy who wrote it tried to reinvent every wheel he could, and badly. He stopped getting work from us because of his bad code that nobody on the team could stand. If it were easy to refactor I would have. Eventually after many 'just do this small 10minute change' situations had ballooned into hours of lost time (regardless of who on the team was doing the work) my boss finally caved in it was rewritten.

    Read the article

  • How should I take being told that I was wrong?

    - by Chris
    On a fairly important project with short timelines I decided to use SubSonic for straight forward data access. I wired up a handful of forms, created matching database tables and POCO's for each and used SubSonic's simple repository mode for the data access. Everything worked well and I was able to bang these forms out pretty quickly and I moved on to other things. Since that time I have heard that using SubSonic was a 'cowboy move' and that it was implemented 'incorrectly' and that 'the person who used it, didn't even know how to use SubSonic'. What I would like to know is, how should I take this? There were and still are no standards for data access at this company, so there is no violation of a standard. The forms worked exactly as requested and saved the data to the database correctly. And with only spending a few days on the forms instead of weeks, saved a lot of time which was used for other functionality in the project. So in light of all of this, I am confused as to what was 'incorrect'. Am I missing something here? Thanks for your answers.

    Read the article

  • Namespaces are obsolete

    - by Bertrand Le Roy
    To those of us who have been around for a while, namespaces have been part of the landscape. One could even say that they have been defining the large-scale features of the landscape in question. However, something happened fairly recently that I think makes this venerable structure obsolete. Before I explain this development and why it’s a superior concept to namespaces, let me recapitulate what namespaces are and why they’ve been so good to us over the years… Namespaces are used for a few different things: Scope: a namespace delimits the portion of code where a name (for a class, sub-namespace, etc.) has the specified meaning. Namespaces are usually the highest-level scoping structures in a software package. Collision prevention: name collisions are a universal problem. Some systems, such as jQuery, wave it away, but the problem remains. Namespaces provide a reasonable approach to global uniqueness (and in some implementations such as XML, enforce it). In .NET, there are ways to relocate a namespace to avoid those rare collision cases. Hierarchy: programmers like neat little boxes, and especially boxes within boxes within boxes. For some reason. Regular human beings on the other hand, tend to think linearly, which is why the Windows explorer for example has tried in a few different ways to flatten the file system hierarchy for the user. 1 is clearly useful because we need to protect our code from bleeding effects from the rest of the application (and vice versa). A language with only global constructs may be what some of us started programming on, but it’s not desirable in any way today. 2 may not be always reasonably worth the trouble (jQuery is doing fine with its global plug-in namespace), but we still need it in many cases. One should note however that globally unique names are not the only possible implementation. In fact, they are a rather extreme solution. What we really care about is collision prevention within our application. What happens outside is irrelevant. 3 is, more than anything, an aesthetical choice. A common convention has been to encode the whole pedigree of the code into the namespace. Come to think about it, we never think we need to import “Microsoft.SqlServer.Management.Smo.Agent” and that would be very hard to remember. What we want to do is bring nHibernate into our app. And this is precisely what you’ll do with modern package managers and module loaders. I want to take the specific example of RequireJS, which is commonly used with Node. Here is how you import a module with RequireJS: var http = require("http"); .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } This is of course importing a HTTP stack module into the code. There is no noise here. Let’s break this down. Scope (1) is provided by the one scoping mechanism in JavaScript: the closure surrounding the module’s code. Whatever scoping mechanism is provided by the language would be fine here. Collision prevention (2) is very elegantly handled. Whereas relocating is an afterthought, and an exceptional measure with namespaces, it is here on the frontline. You always relocate, using an extremely familiar pattern: variable assignment. We are very much used to managing our local variable names and any possible collision will get solved very easily by picking a different name. Wait a minute, I hear some of you say. This is only taking care of collisions on the client-side, on the left of that assignment. What if I have two libraries with the name “http”? Well, You can better qualify the path to the module, which is what the require parameter really is. As for hierarchical organization, you don’t really want that, do you? RequireJS’ module pattern does elegantly cover the bases that namespaces used to cover, but it also promotes additional good practices. First, it promotes usage of self-contained, single responsibility units of code through the closure-based, stricter scoping mechanism. Namespaces are somewhat more porous, as using/import statements can be used bi-directionally, which leads us to my second point… Sane dependency graphs are easier to achieve and sustain with such a structure. With namespaces, it is easy to construct dependency cycles (that’s bad, mmkay?). With this pattern, the equivalent would be to build mega-components, which are an easier problem to spot than a decay into inter-dependent namespaces, for which you need specialized tools. I really like this pattern very much, and I would like to see more environments implement it. One could argue that dependency injection has some commonalities with this for example. What do you think? This is the half-baked result of some morning shower reflections, and I’d love to read your thoughts about it. What am I missing?

    Read the article

  • Lesser-known Github features that I'm missing out on with Bitbucket? [closed]

    - by Ghopper21
    I've been using Bitbucket for my small-team development projects, with the assumption that it is more-or-less a Github clone with pricing that is better for my situation and support for Mercurial (which I don't need). However, I'm seeing there are material-if-not-overwhelming differences, e.g. Github's appealing and useful branches page versus Bitbucket's overly simple branch drop-down list. This makes me wonder: what else am I missing out on? What are the lesser known Github features that folks like me using Bitbucket to save money are missing out on? EDIT: following closure, I've asked for advice on making this question productive over at meta. See here.

    Read the article

  • s expression representation for c

    - by wirrbel
    Experimenting with various lisps lately (clojure especially) i have wondered if there are any s expression based representations of (subsets) of c, so you could use lisp/closure to write macros and then convert the s-expression c tree to pure c. I am not asking for a to-c-compilers of lisp/scheme/clojure but more of using lisps to transform a c syntax tree. Little background to why i am asking this question: i find myself to really enjoy certain clojure macros like the threading macros -> doto etc. And i feel that they would be great in a non FP environment as well.

    Read the article

  • Layers - Logical seperation vs physical

    - by P.Brian.Mackey
    Some programmers recommend logical seperation of layers over physical. For example, given a DL, this means we create a DL namespace not a DL assembly. Benefits include: faster compilation time simpler deployment Faster startup time for your program Less assemblies to reference Im on a small team of 5 devs. We have over 50 assemblies to maintain. IMO this ratio is far from ideal. I prefer an extreme programming approach. Where if 100 assemblies are easier to maintain than 10,000...then 1 assembly must be easier than 100. Given technical limits, we should strive for < 5 assemblies. New assemblies are created out of technical need not layer requirements. Developers are worried for a few reasons. A. People like to work in their own environment so they dont step on eachothers toes. B. Microsoft tends to create new assemblies. E.G. Asp.net has its own DLL, so does winforms. Etc. C. Devs view this drive for a common assembly as a threat. Some team members Have a tendency to change the common layer without regard for how it will impact dependencies. My personal view: I view A. as silos, aka cowboy programming and suggest we implement branching to create isolation. C. First, that is a human problem and we shouldnt create technical work arounds for human behavior. Second, my goal is not to put everything in common. Rather, I want partitions to be made in namespaces not assemblies. Having a shared assembly doesnt make everything common. I want the community to chime in and tell me if Ive gone off my rocker. Is a drive for a single assembly or my viewpoint illogical or otherwise a bad idea?

    Read the article

  • Live EBS Webcasts Coming Up Soon

    - by LuciaC
    There are a number of live webcasts coming up in the next couple of weeks.  Webcasts are free for Oracle Support customers and are an opportunity to learn about a topic from a product expert as well as ask questions directly.  Here is a reminder of what's available and how to register. Product Area Topic Date/Time Register & Details BI Publisher EBS BI/XML Publisher Overview & Best Practices 22 October, 2200 PT Doc ID 1582767.1 Receivables Receivables Release 12 Late Charges Functionality 23 October, 0800 PT Doc ID 1581280.1 WMS Advanced Catch-Weight with WMS 23 October, 1000 PT Doc ID 1583954.1 Install Base Endeca Extension for Oracle Install Base 24 October, 0830 PT Doc ID 1583876.1 WIP Understanding Work Order Closure 30 October, 0800 PT Doc ID 1584358.1 EAM Collection Plans Within E-Business Suite 31 October, 0800 PT Doc ID 1583924.1 All the webcasts are recorded which means you can play them back whenever is convenient for you if you can't join the live session. You can access the recordings as well as the current webcast schedule from Doc ID 740966.1.

    Read the article

  • Don’t Panic! Hides Applications, Erases Browser History, and More

    - by Jason Fitzpatrick
    Don’t Panic! is a free and portable Windows application that makes it easy to quickly hide windows, clear document and browser history, and otherwise mask your goofing off. It includes options for hiding and closing applications, clearing browser history as well as recent clearing the Recent Documents menu and the Recycle Bin. Application closure/hiding is governed by as simple blacklist; populate the blacklist and hit the panic button (or the user-customizable panic button shortcut, CTRL+P by default). Don’t Panic! is free portable application, Windows only. Hit up the link below to read more and grab a copy. Don’t Panic! [Portable Apps] How To Make a Youtube Video Into an Animated GIFHTG Explains: What Are Character Encodings and How Do They Differ?How To Make Disposable Sleeves for Your In-Ear Monitors

    Read the article

  • High-level description of how experimental C++ features are developed?

    - by Praxeolitic
    Herb Sutter in a video answers a question about the concepts proposal considered for C++11 and from his remarks it sounds like multiple groups offered prototype implementations but all of them left concerns about slow compile times. The comment surprised me because it suggests that, at least in some cases, the prototypes being developed are not just proofs of concept -- they're even expected to perform. All the work that must take has me curious. For mature languages, especially C++, how are experimental language features developed? Is it much different from developing a compiler that implements a standard? Does a developer have a sense of if it will work and perform or even if it ever could? What are the most time consuming parts and are any parts surprisingly easier than one might expect? The question is not what does the C++ standards committee do, but rather the part that comes before. When an experimental implementation for a proposal is being put together and there aren't any completely solidified rules, how is the sausage made? I'm not a professional compiler developer nor do I expect answers with step by step accounts. I'd like a high-level idea of how this would be done or if there are any general patterns at all. I don't know what to expect from the answers but even if there are no rules to the process and the small number of people who do this just cowboy it and then, for stuff that worked out, write up the "official version" as a proposal, that answer would still be informative.

    Read the article

  • JavaScript: Alternative to JQuery's (dual) Slider control?

    - by GregJohn
    I am using the JQuery Slider control for use as a double sided slider (dual slider). It's a great UI control but I'm looking for an alternative that isn't so "fat". Right now, just for me to use the Slider control, I have to include: JQuery core JQuery UI core JQuery Slider plugin When I both minimize using Google's awesome Closure (minimizer) and GZIP the JavaScript, I'm still at around 29kb. Question: Do any comparable (dual) Slider control exist that isn't such a large download?

    Read the article

  • Does Java need closures?

    - by Bill the Lizard
    I've been reading a lot lately about the next release of Java possibly supporting closures. I feel like I have a pretty firm grasp on what closures are, but I can't think of a solid example of how they would make an Object-Oriented language "better". Can anyone give me a specific use-case where a closure would be needed (or even preferred)?

    Read the article

  • LINQ and Storedprocedure

    - by Amutha
    The interview i faced was "What is the difference between LINQ and Stored procedure?". I don't know whether it is a vague question or proper one. I answered "In Linq there is a support for Closure so you can refer the value of outer parameter inside the anonymous body,you can't do the same with Stored procedure". Just i am requesting you the proper answer.

    Read the article

  • Queue ExternalInterface calls to Flash Object in UpdatePanel - Needs Improvement?

    - by Laramie
    A Flash (actually Flex) object is created on an ASP.Net page within an Update Panel using a modified version of the embedCallAC_FL_RunContent.js script so it can be written in dynamically. It is re-created with this script with each partial postback to that panel. There are also other Update Panels on the page. With some postbacks (partial and full), External Interface calls such as $get('FlashObj').ExternalInterfaceFunc('arg1', 0, true); are prepared server-side and added to the page using ScriptManager.RegisterStartupScript. They're embedded in a function and stuffed into Sys.Application's load event, for example Sys.Application.add_load(funcContainingExternalInterfaceCalls). The problem is that because the Flash object's state state may change with each partial postback, the Flash (Flex) object and/or External Interface may not be ready or even exist yet in the DOM when the JavaScript - Flash External Interface call is made. It results in an "Object doesn't support this property or method" exception. I have a working strategy to make the ExternalInterface calls immediately if Flash is ready or else queue them until such time that Flash announces its readiness. //Called when the Flash object is initialized and can accept ExternalInterfaceCalls var flashReady = false; //Called by Flash when object is fully initialized function setFlashReady() { flashReady = true; //Make any queued ExternalInterface calls, then dequeue while (extIntQueue.length > 0) (extIntQueue.shift())(); } var extIntQueue = []; function callExternalInterface(flashObjName, funcName, args) { //reference to the wrapped ExternalInterface Call var wrapped = extWrap(flashObjName, funcName, args); //only procede with ExternalInterface call if the global flashReady variable has been set if (flashReady) { wrapped(); } else { //queue the function so when flashReady() is called next, the function is called and the aruments are passed. extIntQueue.push(wrapped); } } //bundle ExtInt call and hold variables in a closure function extWrap(flashObjName, funcName, args) { //put vars in closure return function() { var funcCall = '$get("' + flashObjName + '").' + funcName; eval(funcCall).apply(this, args); } } I set the flashReady var to dirty whenever I update the Update Panel that contains the Flash (Flex) object. ScriptManager.RegisterClientScriptBlock(parentContainer, parentContainer.GetType(), "flashReady", "flashReady = false;", true); I'm pleased that I got it to work, but it feels like a hack. I am still on the learning curve with respect to concepts like closures why "eval()" is apparently evil, so I'm wondering if I'm violating some best practice or if this code should be improved, if so how? Thanks.

    Read the article

  • Implementing dynamic scope when using CPS as intermediate language

    - by asandroq
    I am currently studying the implementation of programming languages and became interested in using Continuation-Passing Style as the intermediate language of the compiler. I also want to implement limited dynamic scope (for exception-handling or Scheme parameter objects) but I cannot find the relevant literature. I think it can be done with a separate environment passed as a variable to every closure, but this solution seems ugly to me. Could anyone point me to the relevant literature, or give me an idea of how this can be done?

    Read the article

  • What are the top javascript pitfalls?

    - by googletorp
    I'm planing on giving an introduction talk on JavaScript and in the preparation process I wondered what the top pitfalls are that rookies fall into. I know I've had a few gotchas before I fully understood closure, but much of the strange behavior in JavaScript is not something I think about any more... So, which pitfalls should you deffinately point out to the rookies?

    Read the article

  • Does this incorporate JavaScript closures?

    - by alex
    In trying to learn JavaScript closures, I've confused myself a bit. From what I've gathered over the web, a closure is... Declaring a function within another function, and that inner function has access to its parent function's variables, even after that parent function has returned. Here is a small sample of script from a recent project. It allows text in a div to be scrolled up and down by buttons. var pageScroll = (function() { var $page, $next, $prev, canScroll = true, textHeight, scrollHeight; var init = function() { $page = $('#secondary-page'); // reset text $page.scrollTop(0); textHeight = $page.outerHeight(); scrollHeight = $page.attr('scrollHeight'); if (textHeight === scrollHeight) { // not enough text to scroll return false; }; $page.after('<div id="page-controls"><button id="page-prev">prev</button><button id="page-next">next</button></div>'); $next = $('#page-next'); $prev = $('#page-prev'); $prev.hide(); $next.click(scrollDown); $prev.click(scrollUp); }; var scrollDown = function() { if ( ! canScroll) return; canScroll = false; var scrollTop = $page.scrollTop(); $prev.fadeIn(500); if (scrollTop == textHeight) { // can we scroll any lower? $next.fadeOut(500); } $page.animate({ scrollTop: '+=' + textHeight + 'px'}, 500, function() { canScroll = true; }); }; var scrollUp = function() { $next.fadeIn(500); $prev.fadeOut(500); $page.animate({ scrollTop: 0}, 500); }; $(document).ready(init); }()); Does this example use closures? I know it has functions within functions, but is there a case where the outer variables being preserved is being used? Am I using them without knowing it? Thanks Update Would this make a closure if I placed this beneath the $(document).ready(init); statement? return { scrollDown: scrollDown }; Could it then be, if I wanted to make the text scroll down from anywhere else in JavaScript, I could do pageScroll.scrollDown(); I'm going to have a play around on http://www.jsbin.com and report back

    Read the article

  • online CSS optimizer?

    - by Dand
    Is there an online CSS optimizer equivalent to Googles JavaScript Closure Optimizer. I've found plenty of CSS compressors online, but I'm looking for a CSS optimizer ... where it actually removes redundant/conflicting attributes

    Read the article

  • Updating an atom with a single value

    - by mikera
    I have a number of atoms in my code where a common requirement is to update them to a new value, regardless of the current value. I therefore find myself writing something like this: (swap! atom-name (fn [_] (identity new-value))) This works but seems pretty ugly and presumably incurs a performance penalty for constructing the anonymous closure. Is there a better way?

    Read the article

  • javascript object's - private methods: which way is better.

    - by Praveen Prasad
    (function () { function User() { //some properties } //private fn 1 User.prototype._aPrivateFn = function () { //private function defined just like a public function, //for convetion underscore character is added } //private function type 2 //a closure function _anotherPrivateFunction() { // do something } //public function User.prototype.APublicFunction = function () { //call private fn1 this._aPrivateFn(); //call private fn2 _anotherPrivateFunction(); } window.UserX = User; })(); //which of the two ways of defining private methods of a javascript object is better way, specially in sense of memory management and performance.

    Read the article

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