Daily Archives

Articles indexed Sunday June 1 2014

Page 12/14 | < Previous Page | 8 9 10 11 12 13 14  | Next Page >

  • Does my use of the strategy pattern violate the fundamental MVC pattern in iOS?

    - by Goodsquirrel
    I'm about to use the 'strategy' pattern in my iOS app, but feel like my approach violates the somehow fundamental MVC pattern. My app is displaying visual "stories", and a Story consists (i.e. has @properties) of one Photo and one or more VisualEvent objects to represent e.g. animated circles or moving arrows on the photo. Each VisualEvent object therefore has a eventType @property, that might be e.g. kEventTypeCircle or kEventTypeArrow. All events have things in common, like a startTime @property, but differ in the way they are being drawn on the StoryPlayerView. Currently I'm trying to follow the MVC pattern and have a StoryPlayer object (my controller) that knows about both the model objects (like Story and all kinds of visual events) and the view object StoryPlayerView. To chose the right drawing code for each of the different visual event types, my StoryPlayer is using a switch statement. @implementation StoryPlayer // (...) - (void)showVisualEvent:(VisualEvent *)event onStoryPlayerView:storyPlayerView { switch (event.eventType) { case kEventTypeCircle: [self showCircleEvent:event onStoryPlayerView:storyPlayerView]; break; case kEventTypeArrow: [self showArrowDrawingEvent:event onStoryPlayerView:storyPlayerView]; break; // (...) } But switch statements for type checking are bad design, aren't they? According to Uncle Bob they lead to tight coupling and can and should almost always be replaced by polymorphism. Having read about the "Strategy"-Pattern in Head First Design Patterns, I felt this was a great way to get rid of my switch statement. So I changed the design like this: All specialized visual event types are now subclasses of an abstract VisualEvent class that has a showOnStoryPlayerView: method. @interface VisualEvent : NSObject - (void)showOnStoryPlayerView:(StoryPlayerView *)storyPlayerView; // abstract Each and every concrete subclass implements a concrete specialized version of this drawing behavior method. @implementation CircleVisualEvent - (void)showOnStoryPlayerView:(StoryPlayerView *)storyPlayerView { [storyPlayerView drawCircleAtPoint:self.position color:self.color lineWidth:self.lineWidth radius:self.radius]; } The StoryPlayer now simply calls the same method on all types of events. @implementation StoryPlayer - (void)showVisualEvent:(VisualEvent *)event onStoryPlayerView:storyPlayerView { [event showOnStoryPlayerView:storyPlayerView]; } The result seems to be great: I got rid of the switch statement, and if I ever have to add new types of VisualEvents in the future, I simply create new subclasses of VisualEvent. And I won't have to change anything in StoryPlayer. But of cause this approach violates the MVC pattern since now my model has to know about and depend on my view! Now my controller talks to my model and my model talks to the view calling methods on StoryPlayerView like drawCircleAtPoint:color:lineWidth:radius:. But this kind of calls should be controller code not model code, right?? Seems to me like I made things worse. I'm confused! Am I completely missing the point of the strategy pattern? Is there a better way to get rid of the switch statement without breaking model-view separation?

    Read the article

  • Storing editable site content?

    - by hmp
    We have a Django-based website for which we wanted to make some of the content (text, and business logic such as pricing plans) easily editable in-house, and so we decided to store it outside the codebase. Usually the reason is one of the following: It's something that non-technical people want to edit. One example is copywriting for a website - the programmers prepare a template with text that defaults to "Lorem ipsum...", and the real content is inserted later to the database. It's something that we want to be able to change quickly, without the need to deploy new code (which we currently do twice a week). An example would be features currently available to the customers at different tiers of pricing. Instead of hardcoding these, we read them from database. The described solution is flexible but there are some reasons why I don't like it. Because the content has to be read from the database, there is a performance overhead. We mitigate that by using a caching scheme, but this also adds some complexity to the system. Developers who run the code locally see the system in a significantly different state compared to how it runs on production. Automated tests also exercise the system in a different state. Situations like testing new features on a staging server also get trickier - if the staging server doesn't have a recent copy of the database, it can be unexpectedly different from production. We could mitigate that by committing the new state to the repository occasionally (e.g. by adding data migrations), but it seems like a wrong approach. Is it? Any ideas how best to solve these problems? Is there a better approach for handling the content that I'm overlooking?

    Read the article

  • Combining two MVC frameworks in a project

    - by SASM
    Is it any good to combine two MVC frameworks together in a project? Is it a fairly common approach? I am thinking about using a serverside framework like CodeIgniter/Laravel and client side framework AngularJS in a predominantly CRUD based web project. I am a bit apprehensive about this idea. I think this approach does not get the best out of both frameworks and can kind of get in way of each other making the application needlessly complicated. Are there some good approaches/practices if one wants to combine these frameworks together?

    Read the article

  • how to process document state transition?

    - by brick
    Imagine there is an application (ASP.NET MVC) that processes some documents. The document must be revised several times by different group of users. state/role rules: simple user can only publish document; (priority: low) userGroup1 can switch it to next state or reject it; (priority: higher) userGroup2 can confirm previous state and switch it to next gradual state or reject it; (priority: highest) How to implement such a workflow in ASP.NET MVC? How to impelement UI, views so that group with lower priority can both visually/technically perform only allowed transitions? Can I somehow extend that system: link? Do I need extras like service bus, event sourcing for that?

    Read the article

  • Front-end structure of large scale Django project

    - by Saike
    Few days ago, I started to work in new company. Before me, all front-end and backend code was written by one man (oh my...). As you know, Django app contains two main directories for front-end: /static - for static(public) files and /templates - for django templates Now, we have large application with more than 10 different modules like: home, admin, spanel, mobile etc. This is current structure of files and directories: FIRST - /static directory. As u can see, it is mixed directories with some named like modules, some contains global libs. one more: SECOND - /templates directory. Some directories named like module with mixed templates, some depends on new version =), some used only in module, but placed globally. and more: I think, that this is ugly, non-maintable, put-in-stress structure! After some time spend, i suggest to use this scheme, that based on module-structure. At first, we have version directories, used for save full project backup, includes: /DEPRECATED directory - for old, unused files and /CURRENT (Active) directory, that contains production version of project. I think it's right, because we can access to older or newer version files fast and easy. Also, we are saved from broken or wrong dependencies between different versions. Second, in every version we have standalone modules and global module. Every module contains own /static and /templates directories. This structure used to avoid broken or wrong dependencies between different modules, because every module has own js app, css tables and local images. Global module contains all libraries, main stylesheets and images like logos or favicon. I think, this structure is much better to maintain, update, refactoring etc. My question is: How do you think, is this scheme better than current? Can this scheme live, or it is not possible to implement this in Django app?

    Read the article

  • Best Practice to return responses from service

    - by A9S6
    I am writing a SOAP based ASP.NET Web Service having a number of methods to deal with Client objects. e.g: int AddClient(Client c) = returns Client ID when successful List GetClients() Client GetClientInfo(int clientId) In the above methods, the return value/object for each method corresponds to the "all good" scenario i.e. A client Id will be returned if AddClient was successful or a List< of Client objects will be returned by GetClients. But what if an error occurs, how do I convey the error message to the caller? I was thinking of having a Response class: Response { StatusCode, StatusMessage, Details } where Details will hold the actual response but in that case the caller will have to cast the response every time. What are your views on the above? Is there a better solution? ---------- UPDATED ----------- Is there something new in WCF for the above? What difference will it make If I change the ASP.NET Web Service to a WCF Service?

    Read the article

  • Common Network Administrator Tools

    - by No Time
    I would like to make a custom clump of Network Admin packages, to be able to carry on a thumb drive, to administer Debian based machines. Examples of what I would include so far: nmap traceroute vnstat zenmap * I know every situation may be different, but I would like to build a toolbox I could bring everywhere, and am looking for advice on other tools which would work. (If there is a similar question, I am fine being directed there)

    Read the article

  • dual boot, Sony Viao, all in one portable desktop, not working and crashes

    - by user287513
    I am a fan of Ubuntu but ever since I bought my new computers, both Sony Vaio, I can't get them running together with windows 8.1. When I try wubi, it doesn't show the install box, but some other information box. If I remove wubi from the iso and run it as admin on my desktop, it runs and installs but after rebooting, grub never comes up and it gives the error screen.. On my laptop, I had to make a usb install and partition everything myself and that worked for my laptop, for a little while. Windows boot loader would override and grub wouldn't come up no more, unless I try to boot from usb, with no usb in, and after it reboots because there is no usb, now grub opens, but doesn't cont. That is what happens with my Sony 2 in 1 laptop. My all in one portable just wont boot it period. Bios is the problem but I disabled everything that was necessary. Help

    Read the article

  • Given a used laptop with Ubuntu installed, how do I get past the password demands?

    - by user287494
    Recently given a laptop with Ubuntu 12.1 installed alongside Windows 7. Can only access Ubuntu, which is fine for everyday use (LibreOffice, Firefox, etc.) but there's an authentication password required to install the 500+ updates, and when trying to run anything in terminal, it asks for "quiz's" password. It won't allow me to go into root mode to bypass the password (if that's even a real thing?). I'm completely new to Linux, but am fascinated at the capabilities and would like to mess around some more, but keep getting stopped by these passwords. What do I have to do? Uninstall and re-install? How does one do that if I don't even have access to the Windows 7 OS because it is password protected as well? Thanks in advance for any information and help.

    Read the article

  • Booting Ubuntu EFI on Macbook Pro Apple Bootmanager

    - by user279771
    Following: http://www.rodsbooks.com/ubuntu-efi/ and https://help.ubuntu.com/community/UEFIBooting#Detect_.28U.29EFI_firmware_processor_architecture I have ubuntu booting on my macbook pro with both refined and the native apple loader working, however, I would like to get the "Improving the Boot Method" (i believe it is called the kernel efi stub loader) working with the Apple Boot manager (the article only explains for refined), but have found no articles explaining this. Can anyone help with this? Below is what I have: What I have is the following: /dev/sda apple partitions /boot ext3 (root) ext3 swap side notes: From what I understand, I should have had my boot partition as fat32/hfs+... I can always switch it or copy the kernel to the apple EFI partition. (I tried creating /boot as an hfs+ partition during installation but was unable. Even after installing hfsprogs, although I was able to create an hfs+ partition in gparted I couldn't use the partition as /boot in ubiquity).

    Read the article

  • Dual Frame Buffer on Ubuntu 12.04 Intel HD Graphics 4600 i7-4770

    - by user3692512
    I have 2 monitors connected to the PC, one in HDMI, one in DVI. I have Intel integrated graphics HD4600 Now as far my understanding, both the monitors is connected at the same framebuffer /dev/fb0 How can I detach them and create 2 frame buffers at startup, so that I can directly write to the second monitor, by writing on the /dev/fb1, and not hamper the /dev/fb0, so that x-server can run normally on that?

    Read the article

  • USB Keyboard doesn't work in Ubuntu 14.04

    - by Steven Crossan
    My USB keyboard isn't working in Ubuntu 14.04, but also didn't work in 13.10. I upgraded today in the hope that the issue would be resolved, but it wasn't. The keyboard works in BIOS and GRUB but stops working when I reach the login screen. It is detected by the system, but just doesn't work. Output of lsusb: Bus 002 Device 002: ID 0846:9011 NetGear, Inc. WNDA3100v2 802.11abgn [Broadcom BCM4323] Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 007 Device 002: ID 1532:000d Razer USA, Ltd Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 006 Device 002: ID 060b:2231 Solid Year KSK-6001 UELX Keyboard Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub I added: hid usbhid hid_generic ohci_pci To /etc/initramfs-tools/modules and did update-initramfs -u, but that didn't work. I'm new to Ubuntu/Linux and any help you could provide would be greatly appreciated!

    Read the article

  • Lot of "file not found" when using sudo find / -type s

    - by Andrea Moro
    In the attempt to understand why I keep getting the following error error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' while using the command sudo find / -type s the terminal prompted something like this find: ‘/proc/31348/task/31348/fd/5’: No such file or directory find: ‘/proc/31348/task/31348/fdinfo/5’: No such file or directory find: ‘/proc/31348/fd/5’: No such file or directory find: ‘/proc/31348/fdinfo/5’: No such file or directory What does this mean?

    Read the article

  • Cannot access Windows via grub after new dual-boot Ubuntu install

    - by user287474
    I previously installed Ubuntu on a computer that had Windows XP on it and got it successfully to run alongside it. (access both OS systems) Now I installed Ubuntu again on my MSI notebook with Windows 8.1, and I cannot access the GRUB without hitting escape on startup, and even then, I can no longer open windows. Before all of this, I created a recovery point, file history and saved a back up on a external hard drive incase I did anything wrong. Now how can I revert my computer back to it's state before installation.

    Read the article

  • Can not enter password for sudo [duplicate]

    - by Michael
    This question already has an answer here: add repository to ubuntu from terminal with pgp key 3 answers I have used Ubuntu for several years, and I can not enter password for sudo, and this is when i wanna add a key to public.gpg for itunes10 it dos not work, and the password normal works wite sudo but not in the terminal when i enter: sudo wget -q "http:// deb.playonlinux.com/public.gpg" -o- | sudo apt-get add - and it says this 'sorry try again', and i just had installed itunes10, and have to add a key whit wget to public.gpg, and i tried to enter in the terminal: sudo apt-get update and the password works fine but not whit using sudo wget, and can some one please help.

    Read the article

  • Black screen with blinking cursor after dual boot install 14.04

    - by chillstream
    I have just installed Ubuntu 14.04 on my toshiba laptop along side Windows 7. When the menu comes up to choose which OS to boot into, I can easily boot into Windows 7. I cannot successfully boot into Ubuntu. All I get is a blinking cursor on a black/purple screen. I attempted the nomodeset trick, which was a bit more successful. I got a screen with a lot of code, but then it stopped with a blinking cursor at the bottom and wouldn't load anymore. As a last resort, would returning my laptop to factory settings get rid of linux and the partitions made to the drive? I already did this to my laptop when it was just windows, which is why I thought I might as well try to add Ubuntu. But it's a lengthy process, and if it won't get rid of the partitions and ubuntu, I won't bother. I appreciate any help ~many thanks

    Read the article

  • Graphics hardware warning when updating to 14.04

    - by pacomet
    As I use Ubuntu at work I just update only LTS versions but now I'm not sure if I can/should. As my computer is now ten years old I would change if was mine but as it is owned by my employer I have to work with it. It's not a bad one, it runs fine (this was not true when still had Windows on it ;-). When updating to 14.04, it warns about possible bad/slow performance with Unity 3D so I stop updating as I am at work, not my own computer. As I understand from http://askubuntu.com/a/438958/25305 Nvidia Geforce FX 5500 graphics card is still supported in 14.04. Now, in 12.04, I have driver version 173 and unity 2d runs fine for me. output of /usr/lib/nux/unity_support_test -p OpenGL vendor string: NVIDIA Corporation OpenGL renderer string: GeForce FX 5500/AGP/SSE2 OpenGL version string: 2.1.2 NVIDIA 173.14.39 Not software rendered: yes Not blacklisted: no GLX fbconfig: yes GLX texture from pixmap: yes GL npot or rect textures: yes GL vertex program: yes GL fragment program: yes GL vertex buffer object: yes GL framebuffer object: yes GL version is 1.4+: yes Unity 3D supported: no Should I update? Is it better to stay with 12.04? Thanks

    Read the article

  • I'm trying to install VMWare tools on Ubuntu 12.04.2 LTS and I seem to have a problem with Kernel headers

    - by Pedro Irusta
    I have Ubuntu 12.04.2 LTS installed on a VMware machine on Windows 7 host. I seem to have a problem with Kernel headers when trying to install them I did: sudo apt-get install gcc make build-essential linux-headers-$(uname -r) Reading package lists... Done Building dependency tree Reading state information... Done gcc is already the newest version. build-essential is already the newest version. linux-headers-3.5.0-28-generic is already the newest version. make is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 100 not upgraded. However, when installing VMware tools I get the following error: make[1]: Entering directory `/usr/src/linux-headers-3.5.0-28-generic' CC [M] /tmp/vmware-root/modules/vmhgfs-only/backdoor.o CC [M] /tmp/vmware-root/modules/vmhgfs-only/backdoorGcc32.o CC [M] /tmp/vmware-root/modules/vmhgfs-only/bdhandler.o CC [M] /tmp/vmware-root/modules/vmhgfs-only/cpName.o CC [M] /tmp/vmware-root/modules/vmhgfs-only/cpNameLinux.o CC [M] /tmp/vmware-root/modules/vmhgfs-only/cpNameLite.o CC [M] /tmp/vmware-root/modules/vmhgfs-only/dentry.o CC [M] /tmp/vmware-root/modules/vmhgfs-only/dir.o CC [M] /tmp/vmware-root/modules/vmhgfs-only/file.o /tmp/vmware-root/modules/vmhgfs-only/file.c:122:4: warning: initialization from incompatible pointer type [enabled by default] /tmp/vmware-root/modules/vmhgfs-only/file.c:122:4: warning: (near initialization for ‘HgfsFileFileOperations.fsync’) [enabled by default] CC [M] /tmp/vmware-root/modules/vmhgfs-only/filesystem.o /tmp/vmware-root/modules/vmhgfs-only/filesystem.c:48:28: fatal error: linux/smp_lock.h: No such file or directory compilation terminated. make[2]: *** [/tmp/vmware-root/modules/vmhgfs-only/filesystem.o] Error 1 make[1]: *** [_module_/tmp/vmware-root/modules/vmhgfs-only] Error 2 make[1]: Leaving directory `/usr/src/linux-headers-3.5.0-28-generic' make: *** [vmhgfs.ko] Error 2 make: Leaving directory `/tmp/vmware-root/modules/vmhgfs-only' Any help appreciated!

    Read the article

  • How to edit thousands of html pages at once? [on hold]

    - by Johnsy Omniscient
    I need to edit thousands of pages for a website with dynamic content added manually by the owner throughout 3 years, it has thousands of pages and I'm sure there is a better way to edit them without spending hours opening each one of them. I know it would be easy to just edit the styles.css but page dynamics like the positions of the google ad-boxes are individually edited inside the html of each page, so there is no way to solve this through css. Is there some sort of code, script and macro that can edit the pages at once?

    Read the article

  • search with mobile : does Google just look in the mobile-optimized websites?

    - by Alireza Fallah
    When someone searches a keyword by mobile, does Google search in desktop version of all websites and find the proper result and then prioritize them according to the responsiveness or mobile-optimizing stuff etc OR it just search in the mobile version of the mobile-optimized websites ? I want to create a website with a responsive design, I was wondering that if I should care about SEO in mobile version of the website, or just try to optimize the desktop version for search engines and just care about the design of the mobile version ?

    Read the article

  • Wordpress login area for downloads

    - by user2248809
    I need to create a page that requires users to log in with a username / email and password to access it, and then depending on who the user is, they get links to one more files they can download. No need for a 'register' page - users will be added on the back-end. Can anyone recommend the best approach for this? Are there good plugins to handle this kind of thing? Thanks in advance for any guidance. It's Wordpress 3.8.1 by the way.

    Read the article

  • Box2D random crash when adding joints

    - by user46624
    I'm currently working on a project which uses Box2D, when the player uses a certain key it should anchor to the ground. For that I use a weld joint, but when I add the joint the game will sometimes crash, it has a 1/10 change to crash. The error I recieve: Showing the controller Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 11 at org.jbox2d.dynamics.Island.add(Island.java:577) at org.jbox2d.dynamics.World.solve(World.java:1073) at org.jbox2d.dynamics.World.step(World.java:598) The code for adding the joints: WeldJointDef def = new WeldJointDef(); def.initialize(body, anchoredObject.body, body.getWorldCenter()); weldJoint = (WeldJoint) world.createJoint(def); I still get the error if I synchronize it

    Read the article

  • How do I reconfigure my GLES frame buffer after a rotation?

    - by Panda Pajama
    I am implementing interface rotation for my GLES based game for iOS, written in Xamarin.iOS with OpenTK. I am detecting the rotation by overriding WillRotate, in my UIViewController, and I correctly re-setup all of my projection matrices. However, when drawing a sprite, the image looks a bit blurrier on the landscape version compared to the portrait version, as you can see in the following closeups magnified 10x. Portrait (before rotating) Landscape (after rotating) In both cases, I'm using the same texture with the same sampler, the same shader, and the same GL state. I just changed the order of the parameters in the projection matrix, so the resulting sizes should be exactly the same pixelwise. Since this could be thought of as a window resize, I suppose that the framebuffer has to be recreated to the new size. When working on desktop apps on Direct3D11 (SharpDX), I would have to call swapChain.ResizeBuffers() to do this. I have tried setting AutoResize = true in my iPhoneOSGameView, but then the framebuffer gets clipped as I rotate the interface, and then everything disappears when rotating the interface again. I'm not doing anything strange, my framebuffer initialization is pretty vanilla: int scaling = (int)UIScreen.MainScreen.Scale; DeviceWidth = (int)UIScreen.MainScreen.Bounds.Width * scaling; DeviceHeight = (int)UIScreen.MainScreen.Bounds.Height * scaling; Size = new System.Drawing.Size((int)(DeviceWidth), (int)(DeviceHeight)); Bounds = new System.Drawing.RectangleF(0, 0, DeviceWidth, DeviceHeight); Frame = new System.Drawing.RectangleF(0, 0, DeviceWidth, DeviceHeight); ContextRenderingApi = EAGLRenderingAPI.OpenGLES2; AutoResize = true; LayerRetainsBacking = true; LayerColorFormat = EAGLColorFormat.RGBA8; I get inconsistent results when changing Size, Bounds and Frame on my CreateFrameBuffer override, but since the documentation is so incomplete (it has nothing on Bounds and Frame), I have resorted to randomly changing stuff here and there without really knowing what is going on. There is a similar question which has no answers. However, I don't know if they're experiencing the same problem as I am. Is my supposition that recreating the framebuffer is necessary, correct? If so, does anybody know how to do it correctly in OpenTK for Xamarin.iOS?

    Read the article

  • After one has made many grid based puzzles how does one make then into a PDF ready for printing

    - by alan ross
    After one has generated many grid based puzzles like sudoku, kakuro or even plain crosswords and now one has to print them in a book. How does one make a pdf (book file) from them automatically. To explain the question better. One has the puzzle ready in computer format like ..35.6.89 for all nine rows. The dot being the empty cell. How does one convert then to a picture on a PDF page complete with box, automatically without doing them individually and then print a book from the pdf file. As can be seen there are other things also printed on the page all this is done automatically.

    Read the article

  • draw fog of war using shaders

    - by lezebulon
    I am making a RTS game, and I'd like some advice on how to best render fog of wars, given what I'm already doing. You can imagine this game as being a classic RTS like Age of Empires 2, where the fog of war will basically be handled by a 2D array telling if a given "tile" is explored or not. The specific things to consider here are : 1) I'm only doing a few draw calls to draw the whole screen, using shaders, and I'm not drawing "tile by tile" in a 2D loop 2) The whole map is much bigger than the screen, and the screen can move every frame or so In that case, how could I draw the fog of war ? I have no issue maintaining on the CPU-side a 2D array giving the fog of war for each tile, but what would be the best way to actually display it dynamically ? thanks!

    Read the article

< Previous Page | 8 9 10 11 12 13 14  | Next Page >