reusability

How to get a module with different type for code reuse?

∥☆過路亽.° 提交于 2019-12-12 04:21:15
问题 Now I have two modules. The functions in the two modules are exactly the same, but one is all about coping with real type, while another is about complex type. All these modules will be used in one program, thus according to different parameter input, we need to choose different modules. According to the major spirit of "code reuse", how to make these modules into one copy of code. And these modules require high performances(thus one need to avoid to use something like "if", "select"). I

Java Swing, 100 TextFields have similar task, So I want to write the one function to do so

风流意气都作罢 提交于 2019-12-12 03:52:40
问题 I am working on a small project (with NetBeans' Java GUI Builder) in which I have 100 TextFields which does exact same thing on different data . They are arranged in 10 rows and 10 columns , there (Variable) names are like: txt11, txt12, ... txt110 txt21, txt22, ... txt210 . . ... . txt101, txt102, ... txt1010 so, that there names can easily generated by the row and column number as well as I can easily extract the row and the column of a TextField to which it belongs (But I can not). Since

Reuse a LINQ To Entities statement

情到浓时终转凉″ 提交于 2019-12-11 20:07:36
问题 I have the following Select expression that will be performed database-side: var model = new ProductListViewModel() { Products = products .Select(q => new ProductViewModel() { // Other mapping Name = q.LanguageKey.LanguageValues.FirstOrDefault(p => p.LanguageKeyID == currentLanguageID && p.Active).Value, }) .OrderBy(q => q.Name) }; As you can see, the Name part is quite long, and other part of my program also use the same logic. Therefore, I would like to reuse it (not entire Select statement

Reusing ASP.NET code in multiple pages

不羁岁月 提交于 2019-12-11 19:39:52
问题 Is there a way to reuse a piece of ASP.NET code (that tag-based code, not the code-behind) in many different pages? For example I have a <div> with some contents in it that appears in 5 different pages of my site. I'm looking for a technique through which I could save this <div> in a separate web-content file so to speak, with maybe a different extension like MyDiv.ASPC and could then do a server-side tag anywhere in a webpage like: <asp:Import href="~/MyDiv.aspc" /> and ASP.NET would inject

How can I reuse classes in my VB6 application?

≯℡__Kan透↙ 提交于 2019-12-11 18:45:31
问题 First of all, as I am using VB6, please confine your kind suggestions to techniques applied to VB6. I have a set of controls related to each other as the above figure shows. It includes several treeviews, a split bar, a listview, a subform( a usercontrol), and etc. When I click or change the treeview nodes in the left, the right controls will change their display accordingly, and vice versa. The data behind the scene is maintained in an Access database. This set of data management and display

Why do I keep getting exception when re-using bitmaps?

南楼画角 提交于 2019-12-11 15:00:05
问题 background starting from API 11, you can re-use bitmaps when you decode new ones, so that the decoder won't need to re-create totally new large objects. this is done using something like this code (taken from this tutorial) : mCurrentBitmap = Bitmap.createBitmap(imageWidth,imageHeight,Bitmap.Config.ARGB_8888); bitmapOptions.inJustDecodeBounds = false; bitmapOptions.inBitmap = mCurrentBitmap; bitmapOptions.inSampleSize = 1; mCurrentBitmap = BitmapFactory.decodeResource(getResources()

How to Re-use an xib subclass of UIView in UITableViewCell

萝らか妹 提交于 2019-12-11 14:18:14
问题 So I'm a newbie and trying some reusability. I've a class called SingleButtonFooterView which subclasses UIView and UI is done in an .xib . Now I want to use this in a UITableViewCell . I've tried almost all possible solutions nothing is working for me. Code for the class: class SingleButtonFooterView: UIView { @IBOutlet weak var button: Button50! override init(frame: CGRect) { super.init(frame: frame) commonInit() } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder)

custom component reuse with extjs4

梦想与她 提交于 2019-12-11 03:30:13
问题 I have created a custom grid in a javascript file. I want to use it as a xtype on to different panels in seperate js files. If I use it on a single panel, it works fine; but when I use try it use it on different panels at the same time, I get a error in the chrome developer tool console saying: Uncaught TypeError: Cannot read property 'isComponent' of undefined My grid definition is as follows: Ext.define('DataBox.view.FootNotes', { extend : 'Ext.grid.Panel', alias : 'widget.footNotes',

what is benefit from socket reuse in C#

纵饮孤独 提交于 2019-12-11 02:00:22
问题 I am developing open source socket server library: https://sourceforge.net/projects/socketservers/ And I would to like to add socket reuse feature to this lib. I have implement draft of this feature, but I do not see any benefits in my tests. The client makes 32K connect-disconnects by 8 items to the server and measure the time. But here is no difference between reusing socket and not reusing socket - same time elapsed for this test. What I am doing wrong in test? What benefit should server

CLOS: how to call a less specific method?

旧街凉风 提交于 2019-12-10 16:13:55
问题 There is a generic method, say incx . There are two versions of incx . One specialized on type a , and one specialized on type b . Type b is a subclass of a . You are given an object of type b , the derived type - but you want to call the method that is specialized on type a . You could do this easily if there wasn't already a method of the same name specialized on type b , but alas, there is such a method. So how do you call the method specialized on type a in such a situation? (defclass a (