Search Results

Search found 5123 results on 205 pages for 'functional dependencies'.

Page 28/205 | < Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >

  • Moving Function With Arguments To RequireJS

    - by Jazimov
    I'm not only relatively new to JavaScript but also to RequireJS (coming from string C# background). Currently on my web page I have a number of JavaScript functions. Each one takes two arguments. Imagine that they look like this: functionA(x1, y1) { ... } functionB(x2, y2) { ... } functionC(x3, y3) { ... } Currently, these functions exist in a tag on my HTML page and I simply call each as needed. My functions have dependencies on KnockoutJS, jQuery, and some other JS libraries. I currently have Script tags that synchronously load those external .js dependencies. But I want to use RequireJS so that they're loaded asynchronously, as needed. To do this, I plan to move all three functions above into an external .js file (a type of AMD "module") called MyFunctions.js. That file will have a define() call (to RequireJS's define function) that will look something like this: define(["knockout", "jquery", ...], function("ko","jquery", ...) {???} ); My question is how to "wrap" my functionA, functionB, and functionC functions where the ??? is above so that I can use those functions on my page as needed. For example, in the onclick event handler for a button on my HTML page, I would want to call functionA and pass two it two arguments; same for functionB and functionC. I don't fully understand how to expose those functions when they're wrapped in a define that itself is located in an external .js file. I know that define assures that my listed libraries are loaded asynchronously before the callback function is called, but after that's done I don't understand how the web page's script tags would use my functions. Would I need to use require to ensure they're available, such as: require(["myfunctions"],function({not sure what to put here})] I think I understand the basics of RequireJS but I don't understand how to wrap my functions so that they're in external .js files, don't pollute the global namespace, and yet can still be called from the main page so that arguments can be passed to them. I imagine they're are many ways to do this but in reviewing the RequireJS docs and some videos out there, I can't say I understand how... Thank you for any help.

    Read the article

  • How do I get a list of the classes compiled into my Flex app?

    - by micapam
    I have several Flex applications in a project, and I would like to know if there's a way to get a list of the classes (and ideally, other assets) that are being compiled into each one. I want an easy way of making sure I've kept things separate and there aren't unnecessary dependencies. Any ideas? I'm running Flash Builder 4.

    Read the article

  • Why are my functional tests failing?

    - by Mongus Pong
    I have generated some scaffolding for my rails app. I am running the generated tests and they are failing. for example test "should create area" do assert_difference('Area.count') do post :create, :area => { :name => 'area1' } end assert_redirected_to area_path(assigns(:area)) end This test is failing saying that : 1) Failure: test_should_create_area(AreasControllerTest) [/test/functional/areas_controller_test.rb:16]: "Area.count" didn't change by 1. <3 expected but was <2. There is only one field in the model : name. I am populating this so it cant be because I am failing to populate the only field. I can run the site and create an area with the name 'area1'. So reality is succeeding, but the test is failing. I cant ask why its failing, because Im sure theres not enough information here for anyone here to know why. Im just stuck at knowing what avenues to go down to work out why the test is failing. Even putting puts into the code dont print out... What steps can I take to track this down?

    Read the article

  • Installed VS Express 2010 with .NET 4.0 and now .NET 3.5 setup project adds 15 dependencies

    - by Heckflosse_230
    Hi, I installed VS Express 2010 with .NET 4.0 and now a .NET 3.5 setup project in VS 2008 adds 15 dependencies (below), what is going on??? I did not change anything in the project in between installing VS 2010, VS 2008 is packagin the following files in the project: ==================== Packaging file 'Microsoft.Transactions.Bridge.dll'... Packaging file 'System.Core.dll'... Packaging file 'System.Data.DataSetExtensions.dll'... Packaging file 'System.Data.Entity.dll'... Packaging file 'System.Data.Linq.dll'... Packaging file 'System.Data.Services.Client.dll'... Packaging file 'System.Data.Services.Design.dll'... Packaging file 'System.IdentityModel.Selectors.dll'... Packaging file 'System.IdentityModel.dll'... Packaging file 'System.Runtime.Serialization.dll'... Packaging file 'System.ServiceModel.Web.dll'... Packaging file 'System.ServiceModel.dll'... Packaging file 'System.Web.Abstractions.dll'... Packaging file 'System.Web.Extensions.dll'... Packaging file 'System.Xml.Linq.dll'... ==================== I've uninstalled VS 2010 and .NET 4.0 but to no avail, same problem. Lesson learned: DON'T EXPERIMENT ON DEVELOPMENT MACHINE! Thanks, Chris

    Read the article

  • Javascript functional inheritance with prototypes

    - by cdmckay
    In Douglas Crockford's JavaScript: The Good Parts he recommends that we use functional inheritance. Here's an example: var mammal = function(spec, my) { var that = {}; my = my || {}; // Protected my.clearThroat = function() { return "Ahem"; }; that.getName = function() { return spec.name; }; that.says = function() { return my.clearThroat() + ' ' + spec.saying || ''; }; return that; } var cat = function(spec, my) { var that = {}; my = my || {}; spec.saying = spec.saying || 'meow'; that = mammal(spec, my); that.purr = function() { return my.clearThroat() + " purr"; }; that.getName = function() { return that.says() + ' ' + spec.name + ' ' + that.says(); }; return that; }; var kitty = cat({name: "Fluffy"}); The main issue I have with this is that every time I make a mammal or cat the JavaScript interpreter has to re-compile all the functions in it. That is, you don't get to share the code between instances. My question is: how do I make this code more efficient? For example, if I was making thousands of cat objects, what is the best way to modify this pattern to take advantage of the prototype object?

    Read the article

  • How to upgrade all dependencies to a specific version

    - by Calm Storm
    Hi, I tried doing a mvn dependency:tree and I get a tree of dependencies. My question is, My project depends on many modules which internally depends on many spring artifacts. There are a few version clashes. I want to upgrade all spring related libraries to say the latest one (2.6.x or above). What is the preferred way to do this? Should I declare all the deps spring-context, spring-support (and 10 other artifacts) in my pom.xml and point them to 2.6.x ? Is there any other better method ? [INFO] +- com.xxxx:yyy-jar:jar:1.0-SNAPSHOT:compile [INFO] | +- com.xxxx:zzz-commons:jar:1.0-SNAPSHOT:compile [INFO] | | +- org.springframework:spring-dao:jar:2.0.7:compile [INFO] | | +- org.springframework:spring-jdbc:jar:2.0.7:compile [INFO] | | +- org.springframework:spring-web:jar:2.0.7:compile [INFO] | | +- org.springframework:spring-support:jar:2.0.7:compile [INFO] | | +- net.sf.ehcache:ehcache:jar:1.2:compile [INFO] | | +- commons-collections:commons-collections:jar:3.2:compile [INFO] | | +- aspectj:aspectjweaver:jar:1.5.3:compile [INFO] | | +- betex-commons:betex-commons:jar:5.5.1-2:compile [INFO] | | \- javax.servlet:servlet-api:jar:2.4:compile [INFO] | +- org.springframework:spring-beans:jar:2.0.7:compile [INFO] | +- org.springframework:spring-jmx:jar:2.0.7:compile [INFO] | +- org.springframework:spring-remoting:jar:2.0.7:compile [INFO] | +- org.apache.cxf:cxf-rt-core:jar:2.0.2-incubator:compile [INFO] | | +- org.apache.cxf:cxf-api:jar:2.0.2-incubator:compile [INFO] | | | +- org.apache.geronimo.specs:geronimo-activation_1.1_spec:jar:1.0-M1:compile [INFO] | | | +- org.codehaus.woodstox:wstx-asl:jar:3.2.1:compile [INFO] | | | +- org.apache.neethi:neethi:jar:2.0.2:compile [INFO] | | | \- org.apache.cxf:cxf-common-schemas:jar:2.0.2-incubator:compile UPDATE : I have removed the extra question about "\-" so my question is now what the subject asks for :)

    Read the article

  • hibernate3-maven-plugin dependencies for newer version of hibernate

    - by Samuel
    I would like to use hibernate-3.5-1.Final along with this plugin, what should be my dependencies here. It seems to be picking up a older set of jars and failing right now. <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>hibernate3-maven-plugin</artifactId> <version>2.2</version> </plugin> EDIT1: [INFO] class org.hibernate.cfg.ExtendedMappings has interface org.hibernate .cfg.Mappings as super class [INFO] -------------------------------------------------------------------- ---- [INFO] Trace java.lang.IncompatibleClassChangeError: class org.hibernate.cfg.ExtendedMap pings has interface org.hibernate.cfg.Mappings as super class at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:621) at java.security.SecureClassLoader.defineClass(SecureClassLoader.ja va:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$000(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmC lassLoader.java:195) at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClas sRealm.java:255) at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLo ader.java:214) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) at org.hibernate.cfg.AnnotationConfiguration.createExtendedMappings (AnnotationConfiguration.java:187) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(Anno tationConfiguration.java:277) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java :1206) at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configurat ion.java:1226) at org.hibernate.ejb.EventListenerConfigurator.configure(EventListe nerConfigurator.java:173) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration. java:854) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration. java:191) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration. java:253)

    Read the article

  • maven dependencies and jetty - avoiding deploy

    - by James Cooper
    Hi, I have a project with 3 artifacts: common - entities, business logic. no UI code webapp-a - a public web app webapp-b - an admin web app webapp-a and webapp-b depend on common. common is configured to deploy to a local maven repo. so far so good. I have IntelliJ configured so that each artifact is a separate module. Module dependencies are configured properly. I can add a new method to a class in common and immediately use that method in a class in a webapp. However, when I run mvn jetty:run it uses the currently deployed common snapshot in my repository. It does not use my local classes. If I add a method to a class in common, it compiles fine, but blows up at runtime. So is it possible to either: a) Convince jetty:run to use my local common build output or b) Deploy my common output to my local ~/.m2/repo while I'm testing locally before I want to commit/deploy or c) some other solution? thank you! -- James

    Read the article

  • Circular Dependencies in XML file

    - by user3006081
    my android xml layout file keeps on Exception raised during rendering: Circular dependencies cannot exist in RelativeLayout Exception details are logged in Window Show View Error Log I cant figure out why? here is my code <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.amandhapola.ribbit.LoginActivity" android:background="@drawable/background_fill" > <ImageView android:id="@+id/backgroundImage" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:scaleType="fitStart" android:src="@drawable/background" android:contentDescription="@string/content_desc_background"/> <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_above="@+id/subtitle" android:layout_centerHorizontal="true" android:textSize="60sp" android:layout_marginTop="32dp" android:textColor="@android:color/white" android:textStyle="bold" android:text="@string/app_name" /> <TextView android:id="@+id/subtitle" android:layout_centerHorizontal="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/title" android:layout_above="@+id/usernameField" android:textSize="13sp" android:textColor="@android:color/white" android:textStyle="bold" android:text="@string/subtitle"/> <EditText android:id="@+id/usernameField" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@+id/passwordField" android:layout_below="@+id/subtitle" android:layout_alignParentLeft="true" android:ems="10" android:hint="@string/username_hint" /> <EditText android:id="@+id/passwordField" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/usernameField" android:layout_above="@+id/loginButton" android:layout_alignParentLeft="true" android:layout_marginBottom="43dp" android:ems="10" android:hint="@string/password_hint" android:inputType="textPassword" /> <Button android:id="@+id/loginButton" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/passwordField" android:layout_above="@+id/signUpText" android:layout_alignParentLeft="true" android:text="@string/login_button_label" /> <TextView android:id="@+id/signUpText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="12dp" android:layout_centerHorizontal="true" android:textColor="@android:color/white" android:layout_below="@+id/loginButton" android:text="@string/sign_up_text" /> </RelativeLayout>

    Read the article

  • Mocking inter-method dependencies

    - by Zecrates
    I've recently started using mock objects in my tests, but I'm still very inexperienced with them and unsure of how to use them in some cases. At the moment I'm struggling with how to mock inter-method dependencies (calling method A has an effect on the results of method B), and whether it should even be mocked (in the sense of using a mocking framework) at all? Take for example a Java Iterator? It is easy enough to mock the next() call to return the correct values, but how do I mock hasNext(), which depends on how many times next() has been called? Currently I'm using a List.Iterator as I could find no way to properly mock one. Does Martin Fowler's distinction between mocks and stubs come into play here? Should I rather write my own IteratorMock? Also consider the following example. The method to be tested calls mockObject.setX() and later on mockObject.getX(). Is there any way that I can create such a mock (without writing my own) which will allow the returned value of getX to depend on what was passed to setX?

    Read the article

  • Automated UAT/functional tests on Swing applications without source code

    - by jas
    Our team is now working on a big Swing application. Our job basically focuses on writing extensions to the existing framework. A typical job would be adding a new panel/ or adding a new tab with some extra functionalities that suit our need. It seems FEST can help a lot in terms of unit-test our code. I am going to try it out this week. But the question here is if there is a way to do automated functional testing on the whole application. In another word, we do not only need to test our code but also the framework. After all, UAT is the most important part. I am currently considering decompiling the jar files we got into source code then we can identify the components and then use FEST. So, before I get started to give this approach a shot, I think I just ask for ideas and inspirations here. There must be people who have done similar things before. Would be nice if I could learn from the veterans who fought against this before . Thanks,

    Read the article

  • StructureMap Issue in Initializing the Dependencies

    - by azamsharp
    I am performing some unit tests and want my MembershipProvider to initialize the dependencies. I run the following code before any test is executed [TestFixtureSetup]. public static void StructureMapConfiguration() { ObjectFactory.Initialize(InitializeUsingScanning); } private static void InitializeUsingScanning(IInitializationExpression obj) { obj.Scan( x => { x.Assembly("EStudyMongoDb.Business"); x.WithDefaultConventions(); } ); } Here is my EstablishContext method which is triggered before running any test: public override void EstablishContext() { _provider = ObjectFactory.GetInstance<MongoDbMembershipProvider>(); _config.Add("applicationName", "EStudyApplication"); _config.Add("name", "EStudyMembershipProvider"); _config.Add("requiresQuestionAndAnswer", "false"); _provider.Initialize(_config["name"], _config); } Here is my test: [TestFixture] public class when_creating_a_new_user : specification_for_membership_provider { public override void When() { _user = _provider.CreateUser("johndoe", "password", "[email protected]", String.Empty, String.Empty, true, null, out _status); } [Test] public void should_create_successfully() { var vUser = Membership.GetUser(_user.UserName); Assert.IsNotNull(vUser); } } Now, in the Membership.GetUser method I try to access the _userRepository but I get null.

    Read the article

  • ASP.NET output caching - dynamically update dependencies

    - by ColinE
    Hi All, I have an ASP.NET application which requires output caching. I need to invalidate the cached items when the data returned from a web service changes, so a simple duration is not good enough. I have been doing a bit of reading about cache dependencies and think I have the right idea. It looks like I will need to create a cache dependency to my web service. To associate the page output with this dependency I think I should use the following method: Response.AddCacheItemDependency(cacheKey); The thing I am struggling with is what I should add to the cache? The dependency my page has is to a single value returned by the web service. My current thinking is that I should create a Custom Cache Dependency via subclassing CacheDependency, and store the current value in the cache. I can then use Response.AddCacheItemDependency to form the dependency. I can then periodically check the value and for a NotifyDependencyChange in order to invalidate my cached HTTP response. The problem is, I need to ensure that the cache is flushed immediately, so a periodic check is not good enough. How can I ensure that my dependant object in the cache which represents the value returned by the web service is re-evaluated before the HTTP response is fetched from the cache? Regards, Colin E.

    Read the article

  • Task predecessor/dependencies logic for task management application

    - by Serge
    Hey guys, I'm trying to figure out the logic for creating tasks that have dependencies. In short I'm building a dynamic task management system and each tasks has several options one of them is to have the task start after a predecessor. Users can add/remove/re-order (by drag&drop) tasks so I'm wondering how can I make the predecessors dynamic, here's an example of what I mean Task 1 Task 2 Task 3 - dependent of task 2 Task 4 - dependent of task 2 Tasks get renamed on delete and/or re-order. If task 1 gets deleted then 3 and 4 should become dependent of task 1 (which is the old task 2). I've been banging my head for the past few hours trying to figure out how to do that. I'm using jQuery right now and each task is contained in a div with an incremental id (ie id="task1") that gets renamed whenever a task is removed or re-ordered and I'm using a dynamically populated drop down for selecting a predecessor. What would be the easiest way to get this done?? by the way, I'm not necessarily asking for code, just trying to figure out the best way to tackle this

    Read the article

  • Customers angry, fighting unknown DLL dependencies

    - by wheaties
    I'm a one man show developing a C++ Windows application for a customer. Over the past several months we've been running to the same problems with missing DLL dependencies on customer machines. Despite my best efforts something keeps going wrong and we get angry emails back. My boss and my boss's boss are angry with me and the customers aren't happy. I'm hoping you guys can help out and give suggestions/ideas on how to get the deliverables in order. Before some of the obvious: I have no test machine. That is, I can't replicate the customer environment nor attempt to install the app on a "clean" system to catch gotchas before shipping. I've tried using depends.exe to track down what versions of the DLLs my project is dependent upon. I'm shipping our code with the redistributables I've been able to find that way. After that it's an angry customer email waiting game. I'm required to use a third-party DLL which can not be registered (it's buggy as hell.) I'm not supposed to use Install Shield, any other automated installer, or write an install script. I provide written instructions on how to get the app installed (unzip, double click exe file.) I'm tired of taking heat for this stuff. What am I missing that I could be doing? What should I ask in terms of support from my employer? How should I ask for that support in a way that they'll provide it?

    Read the article

  • Zend Framework Application: module dependencies

    - by takeshin
    How do you handle dependencies between modules in Zend Framework to create reusable, drop-in modules? E.g. I have Newsletter module, which allows users to subscribe, providing e-mail address. Next, I plan to add Blog module, which allows to subscribe to posts by e-mail (it obviously duplicates some functionality of the newsletter, but the e-mails addresses are stored in User model). Next one is the Forum module, with the same subscribe to post functionality. But I want to have ability to use these modules independent to each one, i.e. application with newsletter alone, newsletter with blog, comibnation two or three modules at once. This is pretty common, e.g. the same story with search feature. I want to have search module, with options to search in all data, blog data or forum data if available. Is there any design pattern for this? Do I have to add some moduleExists($moduleMame), or provide some interface or abstract classes, some base controller pattern, similar for each module?

    Read the article

  • Using Gem Dependencies if a server is 2.0 instead of 2.1

    - by user548744
    At work for internal Rails applications, the server is running Rails 2.0.4 and Ruby 1.86. As far as I know, that's not going to change anytime soon and I have no control over it. I was going to try and test this out between a couple of computers and was curious if anyone knew what would happen. Being the server is on 2.0.4, I'd like to build Rails 2.3.5 applications for that server if at all possible. From what I understand so far, it won't be a problem if I freeze gems and upack dependancies. Does that sound right? Also, the internal work server has no gems beyond what Rails installs. What I'm wondering is, if I can successfully run a 2.3.5 application on the 2.0.4 server, can I also use extra gems and unpack those to use even though the server doesn't have them? I know that it was version 2.1 that introduced Gem Dependencies so would a 2.3.5 Rails app running on a 2.0.4 server be able to use required gems that are unpacked into an application? One of the worst things with this situation is even if the above stuff works, the server being on 1.86 would exclude me from using a lot of really cool gems that require Ruby 1.87 (like Formtastic). Thanks

    Read the article

  • Finding the shortest path between two points on a grid, using Haskell.

    - by esperantist
    This is a problem that I can easily enough solve in a non-functional manner. But solving it in Haskell is giving me big problems. Me being inexperienced when it comes to functional programming is surely a reason. The problem: I have a 2D field divided into rectangles of equal size. A simple grid. Some rectangles are empty space (and can be passed through) while others are impassable. Given a starting rectangle A and a destination rectangle B, how would I calculate the shortest path between the two? Movement is possible only vertically and horizontally, in steps a single rectangle large. How would I go about accomplishing this in Haskell? Code snippets certainly welcome, but also certainly not neccessary. And links to further resources also very welcome! Thanks!

    Read the article

  • Challenge: Neater way of currying or partially applying C#4's string.Join

    - by Damian Powell
    Background I recently read that .NET 4's System.String class has a new overload of the Join method. This new overload takes a separator, and an IEnumerable<T> which allows arbitrary collections to be joined into a single string without the need to convert to an intermediate string array. Cool! That means I can now do this: var evenNums = Enumerable.Range(1, 100) .Where(i => i%2 == 0); var list = string.Join(",",evenNums); ...instead of this: var evenNums = Enumerable.Range(1, 100) .Where(i => i%2 == 0) .Select(i => i.ToString()) .ToArray(); var list = string.Join(",", evenNums); ...thus saving on a conversion of every item to a string, and then the allocation of an array. The Problem However, being a fan of the functional style of programming in general, and method chaining in C# in particular, I would prefer to be able to write something like this: var list = Enumerable.Range(1, 100) .Where(i => i%2 == 0) .string.Join(","); This is not legal C# though. The closest I've managed to get is this: var list = Enumerable.Range(1, 100) .Where(i => i%2 == 0) .ApplyTo( Functional.Curry<string, IEnumerable<object>, string> (string.Join)(",") ); ...using the following extension methods: public static class Functional { public static TRslt ApplyTo<TArg, TRslt>(this TArg arg, Func<TArg, TRslt> func) { return func(arg); } public static Func<T1, Func<T2, TResult>> Curry<T1, T2, TResult>(this Func<T1, T2, TResult> func) { Func<Func<T1, T2, TResult>, Func<T1, Func<T2, TResult>>> curried = f => x => y => f(x, y); return curried(func); } } This is quite verbose, requires explicit definition of the parameters and return type of the string.Join overload I want to use, and relies upon C#4's variance features because we are defining one of the arguments as IEnumerable rather than IEnumerable. The Challenge Can you find a neater way of achieving this using the method-chaining style of programming?

    Read the article

  • Is OO design's strength in semantics or encapsulation?

    - by Phil H
    Object-oriented design (OOD) combines data and its methods. This, as far as I can see, achieves two great things: it provides encapsulation (so I don't care what data there is, only how I get values I want) and semantics (it relates the data together with names, and its methods consistently use the data as originally intended). So where does OOD's strength lie? In constrast, functional programming attributes the richness to the verbs rather than the nouns, and so both encapsulation and semantics are provided by the methods rather than the data structures. I work with a system that is on the functional end of the spectrum, and continually long for the semantics and encapsulation of OO. But I can see that OO's encapsulation can be a barrier to flexible extension of an object. So at the moment, I can see the semantics as a greater strength. Or is encapsulation the key to all worthwhile code?

    Read the article

  • Is JBehave a good choice for Web Service Automated Testing?

    - by Vanchinathan
    Hi All, We have a requirement at my workplace to automate the webservice testing. We have been using QTP scripts to do so. We as a team, Kind of leaning towards Jbehave as a choice. Is JBehave a good choice for web service functional testing automation? We do use Soap UI to test manually. But we are planning to automate the functional and regression testing to reduce the release cycle time. Suggestions welcome.

    Read the article

  • Appending an element to a collection using LINQ

    - by SRKX
    I am trying to process some list with a functional approach in C#. The idea is that I have a collection of Tuple<T,double> and I want to change the Item 2 of some element T. The functional way to do so, as data is immutable, is to take the list, filter for all elements where the element is different from the one to change, and the append a new tuple with the new values. My problem is that I do not know how to append the element at the end. I would like to do: public List<Tuple<T,double>> Replace(List<Tuple<T,double>> collection, T term,double value) { return collection.Where(x=>!x.Item1.Equals(term)).Append(Tuple.Create(term,value)); } But there is no Append method. Is there something else?

    Read the article

  • How can I represent a line of music notes in a way that allows fast insertion at any index?

    - by chairbender
    For "fun", and to learn functional programming, I'm developing a program in Clojure that does algorithmic composition using ideas from this theory of music called "Westergaardian Theory". It generates lines of music (where a line is just a single staff consisting of a sequence of notes, each with pitches and durations). It basically works like this: Start with a line consisting of three notes (the specifics of how these are chosen are not important). Randomly perform one of several "operations" on this line. The operation picks randomly from all pairs of adjacent notes that meet a certain criteria (for each pair, the criteria only depends on the pair and is independent of the other notes in the line). It inserts 1 or several notes (depending on the operation) between the chosen pair. Each operation has its own unique criteria. Continue randomly performing these operations on the line until the line is the desired length. The issue I've run into is that my implementation of this is quite slow, and I suspect it could be made faster. I'm new to Clojure and functional programming in general (though I'm experienced with OO), so I'm hoping someone with more experience can point out if I'm not thinking in a functional paradigm or missing out on some FP technique. My current implementation is that each line is a vector containing maps. Each map has a :note and a :dur. :note's value is a keyword representing a musical note like :A4 or :C#3. :dur's value is a fraction, representing the duration of the note (1 is a whole note, 1/4 is a quarter note, etc...). So, for example, a line representing the C major scale starting on C3 would look like this: [ {:note :C3 :dur 1} {:note :D3 :dur 1} {:note :E3 :dur 1} {:note :F3 :dur 1} {:note :G3 :dur 1} {:note :A4 :dur 1} {:note :B4 :dur 1} ] This is a problematic representation because there's not really a quick way to insert into an arbitrary index of a vector. But insertion is the most frequently performed operation on these lines. My current terrible function for inserting notes into a line basically splits the vector using subvec at the point of insertion, uses conj to join the first part + notes + last part, then uses flatten and vec to make them all be in a one-dimensional vector. For example if I want to insert C3 and D3 into the the C major scale at index 3 (where the F3 is), it would do this (I'll use the note name in place of the :note and :dur maps): (conj [C3 D3 E3] [C3 D3] [F3 G3 A4 B4]), which creates [C3 D3 E3 [C3 D3] [F3 G3 A4 B4]] (vec (flatten previous-vector)) which gives [C3 D3 E3 C3 D3 F3 G3 A4 B4] The run time of that is O(n), AFAIK. I'm looking for a way to make this insertion faster. I've searched for information on Clojure data structures that have fast insertion but haven't found anything that would work. I found "finger trees" but they only allow fast insertion at the start or end of the list. Edit: I split this into two questions. The other part is here.

    Read the article

  • Instantiating Java object with a passed in method

    - by superluminary
    It's been a few years since I've been heavily into Java. Coming back to it I'm seeing this pattern all over the place: ratingBar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() { public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) { // do work } }); This looks more like Functional programming to me. It's a nice pattern but how is it possible to pass a method like this? In the old days a class was a class, and once compiled there was little you could do to it. My questions are: Can anyone let me know what this pattern is called? How can I write a class that can be instantiated in this way. Are there any other useful examples of functional patterns that have made their way into Java? What do I need to Google to read more about this? Thanks.

    Read the article

< Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >