デバッグ戦略
Upcoming SlideShare
Loading in...5
×
 

デバッグ戦略

on

  • 3,184 views

 

Statistics

Views

Total Views
3,184
Views on SlideShare
3,161
Embed Views
23

Actions

Likes
3
Downloads
28
Comments
0

6 Embeds 23

http://paper.li 7
https://twitter.com 5
http://twitter.com 4
http://us-w1.rockmelt.com 3
http://a0.twimg.com 3
https://si0.twimg.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

デバッグ戦略 デバッグ戦略 Presentation Transcript

  • (@v vakame) Android2011 8 25
  • • • • http://www.slideshare.net/vvakame/debugging-strategy2011 8 25
  • 2011 8 25 View slide
  • 2011 8 25 View slide
  • …2011 8 25
  • • • initA() initB() init() A, B public • 2 • ( ) • • …2011 8 25
  • /** * bitmap . * * @param bitmapArrays */ static void dot1PixelA(Bitmap[][] bitmapArrays) { for (int i = 0; i < bitmapArrays.length; i++) { for for (int j = 0; j < bitmapArrays[i].length; i++) { bitmapArrays[j][i].setPixel(0, 0, Color.RED); } } } /** * bitmap . * * @param bitmapArrays */ static void dot1PixelB(Bitmap[][] bitmapArrays) { for (Bitmap[] bitmapArray : bitmapArrays) { for (Bitmap bitmap : bitmapArray) { for-each bitmap.setPixel(0, 0, Color.RED); } } }2011 8 25
  • /** * bitmap . * * @param bitmapArrays */ static void dot1PixelA(Bitmap[][] bitmapArrays) { for (int i = 0; i < bitmapArrays.length; i++) { for for (int j = 0; j < bitmapArrays[i].length; i++) { bitmapArrays[j][i].setPixel(0, 0, Color.RED); } } } /** * bitmap . * * @param bitmapArrays */ static void dot1PixelB(Bitmap[][] bitmapArrays) { for (Bitmap[] bitmapArray : bitmapArrays) { for (Bitmap bitmap : bitmapArray) { for-each bitmap.setPixel(0, 0, Color.RED); } } }2011 8 25
  • Bitmap[][] bitmapArrays = new Bitmap[10][10]; for (int i = 0; i < bitmapArrays.length; i++) { for (int j = 0; j < bitmapArrays[i].length; j++) { bitmapArrays[i][j] = Bitmap.createBitmap(3, 3, Config.ARGB_8888); } } …2011 8 25
  • ADT 2011/08/25 rev122011 8 25
  • 2011 8 25
  • • • • • null2011 8 25
  • • LogCat2011 8 25
  • • L07 @Override L08 public void onCreate(Bundle savedInstanceState) { L09 super.onCreate(savedInstanceState); L10 setContentView(R.layout.main); L11 L12 try { L13 throw new NullPointerException(); L14 } catch (Exception e1) { L15 try { L16 throw new IllegalArgumentException(e1); L17 } catch (Exception e2) { L18 try { L19 throw new IllegalStateException(e2); L20 } catch (Exception e3) { L21 throw new RuntimeException(e3); L22 } L23 } L24 } L25 } Caused2011 8 25
  • • L08 @Override L09 public void onCreate(Bundle savedInstanceState) { L10 super.onCreate(savedInstanceState); L11 setContentView(R.layout.main); L12 requestWindowFeature(Window.FEATURE_NO_TITLE); L13 } L11 L122011 8 25
  • L22 … L09 @Override L10 public void onCreate(Bundle savedInstanceState) { L11 super.onCreate(savedInstanceState); L12 L13 LinearLayout layout1 = new LinearLayout(this); L14 LinearLayout layout2 = new LinearLayout(this); L15 LinearLayout layout3 = new LinearLayout(this); L16 Button button = new Button(this); L17 L18 layout1.addView(layout2); L19 L20 layout2.addView(layout1); layout3.addView(button); layout1 → layout2 → layout1 L21 L22 setContentView(layout1); layout1 → layout2 → layout3 … L23 }2011 8 25
  • “ ” • ( ω ´) • • • ← • …… …… • … orz ←2011 8 25
  • “ ” • • • • … •2011 8 25
  • void sort() { List<String> list = new ArrayList<String>(); list.add("cupcake"); list.add(null); list.add("donuts"); list.add(null); list.add("froyo"); Collections.sort(list, new Comparator<String>() { @Override public int compare(String str1, String str2) { if (str1 == null) { return -1; } return str1.compareTo(str2); } }); Log.d("Debug", list.toString()); } NullPointerException … LogCat …2011 8 25
  • 2011 8 25
  • str2 null String#compareTo(String) null …2011 8 25
  • NPE(NullPointerException)2011 8 25
  • 2011 8 25
  • … public class Util { /** * 2 1 . * @param list1 1 * @param list2 2 * @return 1 */ public static List<Object> merge(List<Object> list1, List<Object> list2) { list1.addAll(list2); return list1; } /** * 1 . * @param lists * @return 1 */ public static List<Object> merge(List<?>... lists) { List<Object> result = new ArrayList<Object>(); for (List<?> list : lists) { result.addAll(list); } return result; } }2011 8 25
  • public void test() { List<Object> list1 = new ArrayList<Object>(); list1.add("a"); list1.add("b"); List<Object> list2 = new ArrayList<Object>(); list2.add(1); list2.add(2); List<Object> list3 = new ArrayList<Object>(); list3.add(1.25); list3.add(2.5); List<Object> merged1 = Util.merge(list1, list2); List<Object> merged2 = Util.merge(list1, list2, list3); assertEquals(merged1.size(), 4); assertEquals(merged1.get(0), "a"); assertEquals(merged1.get(1), "b"); assertEquals(merged1.get(2), 1); assertEquals(merged1.get(3), 2); assertEquals(merged2.size(), 6); assertEquals(merged2.get(0), "a"); assertEquals(merged2.get(1), "b"); assertEquals(merged2.get(2), 1); assertEquals(merged2.get(3), 2); assertEquals(merged2.get(4), 1.25); assertEquals(merged2.get(5), 2.5); }2011 8 25
  • public void test() { List<Object> list1 = new ArrayList<Object>(); list1.add("a"); list1.add("b"); List<Object> list2 = new ArrayList<Object>(); list2.add(1); list2.add(2); List<Object> list3 = new ArrayList<Object>(); list3.add(1.25); list3.add(2.5); List<Object> merged1 = Util.merge(list1, list2); List<Object> merged2 = Util.merge(list1, list2, list3); assertEquals(merged1.size(), 4); assertEquals(merged1.get(0), "a"); assertEquals(merged1.get(1), "b"); assertEquals(merged1.get(2), 1); assertEquals(merged1.get(3), 2); size 8 assertEquals(merged2.size(), 6); assertEquals(merged2.get(0), "a"); assertEquals(merged2.get(1), "b"); assertEquals(merged2.get(2), 1); assertEquals(merged2.get(3), 2); assertEquals(merged2.get(4), 1.25); assertEquals(merged2.get(5), 2.5); }2011 8 25
  • Debug As ...2011 8 25
  • • F8 • F5 1 ( ) • F6 1 ( ) • F72011 8 25
  • 8 …2011 8 25
  • ( )2011 8 25
  • • • , , • Variables • •2011 8 25
  • … ¨ ¨ ¨ ¨ ¨ ¨ ¨ ¨...2011 8 25
  • →Inspect2011 8 25
  • 2011 8 25
  • • • • • • •2011 8 25
  • 2011 8 25
  • OpenGL2011 8 25
  • OpenGL http://t.co/bet40512011 8 25
  • 2011 8 25