code-reuse

How to organise large code files?

拟墨画扇 提交于 2019-12-09 04:52:03
问题 I am increasingly aware that my code in any single file can often span hundreds of lines quite easily and although I know the implementation might be sound, it still feels messy and unorganised. I understand that there are situations where a lot of code is neccessary, but whats the best way to organise it all? I've thought about separating variables from methods, private s from public s and internals but I don't want to because I can't help thinking that the components of ONE class belong in

How to create a reusable toggle button in AS3?

好久不见. 提交于 2019-12-08 18:25:34
I'm trying to make the code below reusable. I need multiple toggle buttons in my flash project. Right now the code below works on one button. If I continue and create more buttons, and follow the format below, I would need to create separate functions for each button. I would like to put the reusable code in a separate ActionScript file and not in the FLA file. I am trying to put the rolloverToggle, rolloverToggle, and toggleClick in a class that I'm making. // /////////////////////////////////////////////////////////////////////// // ------- Need to make this code reusable ------- // ////////

reusable application for django site wide announcements that displays a message only once per user

孤人 提交于 2019-12-08 11:33:31
问题 I want to show various messages to registered users only once in my django application. I found django-announcements which seemed to do what I want - but I found in testing it marks messages as read by using a session variable, which disappears if the user logs out. This means a message is shown again to a user if they dismiss it when logged in, log out, and then log in again. I wondered if anyone know of an application that I might be able to use here without re-inventing the wheel. 回答1:

PHP - Wrap a variable block in the same try-catch

戏子无情 提交于 2019-12-08 06:35:25
问题 in my PHP project, I use Guzzle to make a lot of different API requests. In order to handle all exception, each API call is wrapped into a try-catch block. An example: try { $res = $client->get($url, [ 'headers' => [ 'Authorization' => "bearer " . $jwt, ] ]); } catch (ClientException $clientException) { // Do stuff } catch (ConnectException $connectException) { // Do stuff }catch (RequestException $requestException){ // Do stuff } For each request, the exceptiuon handling is the same but the

How to create generic/reusable code with Scrum? [closed]

烂漫一生 提交于 2019-12-08 06:11:12
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . Scrum development is based on listing user stories and implementing them in during sprints. That approach - focusing on actual goals of the end product - definitely has its virtues, but what bugs me is that it doesn't advocate creating any generic/reusable code in the process, and

How can I reuse code when two different wicket applications share common functionality

会有一股神秘感。 提交于 2019-12-08 05:45:38
问题 I have a Wicket AuthenticatedWebApplication which has several pages and features that need to be reused in a new AuthenticatedWebApplication that I have to develop. I am using Wicket 1.4, Spring and Hibernate. Both applications will even share the same look (except for Application logo) which is now implemented in a base page. Has anyone had a similar experience? I definitely don't want to recur to copy-paste code because the common functionality implements a workflow process which can and

How to create a reusable toggle button in AS3?

北城余情 提交于 2019-12-08 04:50:15
问题 I'm trying to make the code below reusable. I need multiple toggle buttons in my flash project. Right now the code below works on one button. If I continue and create more buttons, and follow the format below, I would need to create separate functions for each button. I would like to put the reusable code in a separate ActionScript file and not in the FLA file. I am trying to put the rolloverToggle, rolloverToggle, and toggleClick in a class that I'm making. // ///////////////////////////////

Android: Custom Clock widget Service work-around?

喜你入骨 提交于 2019-12-08 00:13:48
问题 I was interested in developing a clock widget for the homescreen and upon reading Home Screen Widgets tutorial, I wondered if there is a pre-existing Service I could reference for updating the current time rather than re-inventing the wheel? I download the Retro Clock application on my android phone and noticed that when I click it, it pops up the Alarm Clock settings, but with the default Google Analog Clock widget, upon click does nothing. Is that because the Retro Clock widget implements

Switching between two datasets in this d3.js reusable and zoomable line chart

心已入冬 提交于 2019-12-07 23:00:01
问题 In this example http://bl.ocks.org/4743409 I set up a zoomable line chart containing two lines. But Switching the selection options I obtain a superposition of the two datasets. How can I switch between the two? Thank you in advance for your help and most of all for your suggestions to improve the code. UPDATE: I succeeded in implementing a reusable chart (and I updated the example in the link). Now I have no superposition of the two datasets. However, I still do not understand why the proper

How to re-use forms with some fields left out in Symfony2

 ̄綄美尐妖づ 提交于 2019-12-07 09:03:10
问题 I am using embedded forms to be able to make a registration form, which holds fields of several related entities. As explained to me in my question over here: Symfony2 form where the data objects doesn't match exactly what needs to be filled in This works just fine. But say I want to re-use one of the forms that I embedded, but leave some of the fields out. Then what are my options? Do I create an extra formType which extends the original one? Do I decide in the view to leave some fields out?