builder

Do Rust builder patterns have to use redundant struct code?

一个人想着一个人 提交于 2019-12-07 18:40:05
问题 I was looking at the Method syntax section of the Rust documentation and came across an example of the builder pattern. The CircleBuilder struct in the example below is an exact duplicate of the Circle struct. It seems like this redundant code violates the usual norms of programming. I understand why the example created a new struct, because the creator did not want to implement the builder methods against the original Circle struct. That is fine, but is there a way to rewrite this example so

Rails XML builder with no pretty-printing (i.e. minified XML)

一世执手 提交于 2019-12-07 15:52:16
问题 I am using Builder::XmlMarkup to produce data structures in XML format for a RESTful API server. Recently, I discovered a bug where the pretty-printing from Builder::XmlMarkup produced an element full of whitespace text instead of an empty element as it should. For example, this code: xml.outertag do xml.list do # Some code which loops through a list end end is producing: <outertag> <list> </list> </outertag> When the inner list is an empty list, the element must be empty—i.e. <list/> or

Linker error “contains invalid OMF record”

吃可爱长大的小学妹 提交于 2019-12-07 13:18:31
问题 In C++ Builder when I compile I get [ilink32 Error] Error: 'C:\PATH\TO\A\LIB\INCLUDED\IN\THE\PROJECT\ALIBRARY.LIB' contains invalid OMF record, type 0x21 (possibly COFF) When I convert .lib with utilities coff2omf , new lib looses significant functions. 回答1: C++Builder cannot use .lib files from other compilers, only its own. If the .lib file is an import lib for a DLL, use C++Builder's command-line IMPLIB tool to create a new .lib file from the DLL directly. If the .lib file is a static

Running a shell script using ProcessBuilder

梦想与她 提交于 2019-12-07 11:01:06
问题 I am trying to run a script using Java and ProcessBuilder. When I try to run, I receive the following message: error=2, No such file or directory. I dont know what I am doing wrong but here is my code (ps: I tried to execute just the script without arguments and the error is the same: String[] command = {"/teste/teste_back/script.sh, "+argument1+", "+argument+""}; ProcessBuilder p = new ProcessBuilder(command); try { // create a process builder to send a command and a argument Process p2 = p

Builder Pattern inside vs outside class?

自作多情 提交于 2019-12-07 06:40:22
问题 What are the advantages between using the builder pattern within vs outside the class? Inside class: public class Person { private String name; private String eyeColor; private String hairColor; public Person setName(String name) { this.name = name; return this; } public Person setEyeColor(String eyeColor) { this.eyeColor = eyeColor; return this; } public Person setHairColor(String hairColor) { this.hairColor = hairColor; return this; } } // Example usage: Person p = new Person() .setName(

Rails 3 Installation Hangs at Gem Builder with “unable to convert ”\xF1“ from ASCII-8BIT to UTF-8”

旧街凉风 提交于 2019-12-07 05:40:38
问题 I followed this tutorial http://pragmaticstudio.com/blog/2010/9/23/install-rails-ruby-mac to install Ruby on Rails on Mac OS X (Lion 10.7). Everything went fine until I installed Rails with rvm (v. 1.6) when I received the following messages: Installing RDoc documentation for builder-3.0.0... unable to convert "\xF1" from ASCII-8BIT to UTF-8 for README, skipping unable to convert "\xF1" from ASCII-8BIT to UTF-8 for README.rdoc, skipping** (Builder version succesfully installed 2.1.2) and

Xcode Scene Dock hidden

佐手、 提交于 2019-12-07 03:27:16
问题 My scene dock is hidden... How can I make it visible? The red one is missing 回答1: You can find this button in below left side just click it ..you will get what you need.. Enjoy.. 回答2: Not exactly sure what do you mean by scene dock. But I guess you can see different windows by changing your selection here. 回答3: if so, Click that Hide Document Outline then you ll get that missing window.this is Hide Document Outline button In Xcode you could see the following Menus, File Edit View Navigate

How to fetch liferay entity through custom-finder in custom plugin portlet?

喜夏-厌秋 提交于 2019-12-07 02:18:20
问题 How can we fetch liferay entities through custom-finder using custom SQL? Following is my sql query written in default.xml ( I have trimmed down the query to the bare minimum so that the logic remains simple. Since it included a few functions and joins we couldn't use DynamicQuery API ): SELECT grp.* FROM Group_ WHERE site = 1 AND active_ = 1 AND type_ <> 3 Relevant code in MyCustomGroupFinderImpl.java : Session session = null; try { session = openSession(); // fetches the query string from

Build xib Interface Builder and load them as subview in iphone

孤者浪人 提交于 2019-12-06 16:17:56
问题 what I would like to know if it's possible to build a view and its correspondent xib file. Then, in a generic controller, load this view programmatically and add as a subview to the current view. This subview should act as a generic info box which can be loaded by many controller. thanks Leonardo 回答1: I found solution myself, after looking at some stackoverflow thread. So I would like to share what I found and see if it's an acceptable solution. Basically this is what I did: create a MyView.m

Is there a convention that objects created using the Builder pattern be immutable?

折月煮酒 提交于 2019-12-06 11:30:50
According to the book Design Patterns: Elements of Reusable Object-Oriented Software,: The Builder Pattern separates the construction of a complex object from its representation so that the same construction process can create different representations. In general the Builder pattern solves the issue with large number of optional parameters and inconsistent state by providing a way to build the object step-by-step and provide a method that will actually return the final Object. With the builder pattern we go to have a build method to generate an object witch is immutable. My Question: Can I